How ai-fn/logpretty works
logpretty is an early-stage Go CLI for streaming log lines from stdin to stdout. Its working path handles arguments and signals, reads bounded lines, and flushes output in bursts; long lines are marked when truncated. A separate, implemented parsing subsystem recognizes JSON and logfmt and assigns time, level, and message roles, but the README explicitly says parsing and formatting are not yet wired into the CLI. Filtering, colors, and pretty rendering remain planned capabilities. Edges reflect shown calls; parser-to-CLI wiring is therefore omitted.
Main entry points: app.go CLI pipeline · detect.go Format detection · json.go JSON fields · roles.go Role assignment
Components 13
CLI control
- Command entry
cmd/logpretty/main.go
Stream handling
- CLI pipeline
internal/app/app.go - Bounded line reader
internal/linereader/linereader.go
Parsing model
- Parsed entry
internal/entry/entry.go - Value decoding
internal/entry/value.go - Level vocabulary
internal/entry/level.go - Format detection
internal/parse/detect.go - JSON fields
internal/parse/json.go - Logfmt fields
internal/parse/logfmt.go - Role assignment
internal/parse/roles.go
Other components
- Log producer
- Output reader
- OS signals
Connections 13
- OS signals → Command entry: cancels on
cmd/logpretty/main.go - Command entry → CLI pipeline: runs
cmd/logpretty/main.go - Log producer → CLI pipeline: supplies stdin
internal/app/app.go - CLI pipeline → Bounded line reader: reads lines
internal/app/app.go - CLI pipeline → Output reader: writes output
internal/app/app.go - Format detection → JSON fields: tries JSON
internal/parse/detect.go - Format detection → Logfmt fields: tries logfmt
internal/parse/detect.go - Format detection → Role assignment: assigns roles
internal/parse/detect.go - JSON fields → Parsed entry: builds fields
internal/parse/json.go - Logfmt fields → Parsed entry: builds fields
internal/parse/logfmt.go - Role assignment → Parsed entry: marks roles
internal/parse/roles.go - Role assignment → Level vocabulary: parses levels
internal/parse/roles.go - JSON fields → Value decoding: decodes keys
internal/parse/json.go