log: add OpenTelemetry + text log renderers - #41
Merged
Merged
Conversation
Adds the stripes/log package, a unified renderer for both OpenTelemetry log batches (binary or protojson) and line-oriented text log formats (logfmt, jsonlog, AWS ALB and NGINX access logs, log4j/Kafka, Python logging, Go stdlib log, BSD/RFC 5424 syslog). Every record renders in the same shape — a single header line of fixed-width columns (timestamp, optional level, format-specific metadata, message) followed by indented attribute lines only when the record has any. Timestamps normalise to local time; severities get a fixed 4-char coloured label (TRAC/DEBU cyan, INFO green, WARN yellow, ERRO red, FATA purple). HTTP access logs drop the level column (the status code carries severity), colour the method by class (GET blue, POST orange, PUT magenta, PATCH purple, DELETE pink), and dim the protocol-version suffix. Multi-line content folds into the preceding record's message: matching lines start a new record; non-matching and whitespace-prefixed lines append to it. Stack traces, Go panic dumps, and exception traces stay attached to their log line and render verbatim (no wrapper indent) so the trace's own indentation shows through. The CLI gains --format aliases (logs, logfmt, jsonlog, alb-access, nginx-access, log4j, python-log, go-log, syslog, syslog-rfc5424) and learns to derive compression from the filename when Content-Encoding is absent so .log.gz from S3 "just works." json's Detect now requires a parseable first JSON value so log4j's bracketed timestamps stop tripping it. testdata/log/ ships representative fixtures for each format, including a Go panic in golog.log and a reproducible OTLP binpb generated by testdata/log/gen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stripes/logpackage — one renderer for both OpenTelemetry log batches (binary / protojson, MIMEapplication/vnd.opentelemetry.logs) and line-oriented text log formats (logfmt, jsonlog, AWS ALB, NGINX, log4j/Kafka, Pythonlogging, Go stdliblog, BSD/RFC 5424 syslog).yyyy/mm/dd hh:mm:ss.mmm LEVEL metadata messageheader with attributes indented underneath, keys aligned on a│separator. Timestamps normalise to local time; severity is a fixed 4-char coloured label (TRAC/DEBUcyan,INFOgreen,WARNyellow,ERROred,FATApurple).HTTP/x.yversion suffix.--formataliases and derives compression from the filename whenContent-Encodingis absent, sos3://…/foo.log.gz"just works."json/detectJSONtightened to require a parseable first JSON value, so log4j's bracketed timestamps no longer false-positive into the JSON renderer.Test plan
go build ./...cleango vet ./...cleangofmt -l .cleango test -count=1 ./...— all packages green, including the existingtestdata/script/*.txtardetection-priority teststestdata/script/detect_log.txtarcovers content-based detection across every text log formattestdata/log/fixtures render correctly under their auto-detected format and under explicit--format=flagstestdata/log/otlp.binpb(regenerable viago run ./testdata/log/gen) renders under both--format=logsand--schema=opentelemetry.proto.logs.v1.LogsDatas3://…elasticloadbalancing/…log.gz(auto-decompresses, auto-detects ALB)🤖 Generated with Claude Code