MoonLogLens is a lightweight structured log parser, query engine, and
aggregation helper for MoonBit.
The project targets a practical gap in the MoonBit ecosystem: developers often
need to inspect log streams, filter incidents by fields, and summarize service
behavior without a full observability stack. MoonLogLens focuses on a compact,
dependency-free core that can be tested, published, and reused by other MoonBit
projects.
Features
Parse logfmt-style entries such as
ts=2026-06-04T10:00:00Z level=ERROR service=api msg="request timeout".
Support quoted values, escaped characters, spaces inside values, and
line/column diagnostics.
Parse multi-line log text into structured entries.
Filter entries with a small query language:
level:ERROR service:api text:"timeout" has:trace_id.
Aggregate entries by a field with count_by(entries, "service").
Provide a deterministic CLI demo through moon run cmd/main.
MoonLogLens intentionally keeps the first version small:
The parser scans each line once and builds Array[LogField] values.
The query parser supports field equality, text containment, and field
existence checks.
Query clauses are combined with AND semantics.
Aggregation preserves first-seen bucket order, which makes CLI output stable.
No file I/O, background services, external storage, or third-party MoonBit
packages are required.
This scope makes the package suitable as a contest entry and as a foundation
for future work such as streaming ingestion, richer query syntax, and
observability dashboards.
python123/moonloglens
MoonLogLens is a lightweight structured log parser, query engine, and aggregation helper for MoonBit.
The project targets a practical gap in the MoonBit ecosystem: developers often need to inspect log streams, filter incidents by fields, and summarize service behavior without a full observability stack. MoonLogLens focuses on a compact, dependency-free core that can be tested, published, and reused by other MoonBit projects.
Features
ts=2026-06-04T10:00:00Z level=ERROR service=api msg="request timeout".level:ERROR service:api text:"timeout" has:trace_id.count_by(entries, "service").moon run cmd/main.Quick Start
Example output:
API Example
Public API:
parse_line(input : String) -> Result[LogEntry, LogError]parse_lines(input : String) -> Result[Array[LogEntry], LogError]parse_query(input : String) -> Result[Query, LogError]matches(entry : LogEntry, query : Query) -> Boolfilter(entries : Array[LogEntry], query : Query) -> Array[LogEntry]count_by(entries : Array[LogEntry], key : String) -> Array[CountBucket]get(entry : LogEntry, key : String) -> String?message(entry : LogEntry) -> Stringformat_error(err : LogError) -> StringDesign
MoonLogLens intentionally keeps the first version small:
Array[LogField]values.This scope makes the package suitable as a contest entry and as a foundation for future work such as streaming ingestion, richer query syntax, and observability dashboards.
Competition Materials
docs/competition/proposal.mddocs/competition/acceptance-checklist.mddocs/competition/submission-guide.mddocs/superpowers/specs/2026-06-04-moonloglens-design.mddocs/superpowers/plans/2026-06-04-moonloglens.mdDevelopment
License
Apache-2.0