Skip to main content

Module log

Module log 

Source
Expand description

Span-tree logging for Jan cron scripts and agent pipelines.

Spans live under logs/ in the store root. Each span is a JSON file logs/<id>.json; log events are embedded in the span they belong to. Reading back a span tree walks the directory and reconstructs parent→child relationships in memory.

Layout:

logs/
  <uuid>.json    # one file per span

Span JSON schema:

{
  "id":         "<uuid>",
  "name":       "fetch-prices",
  "parent_id":  "<uuid> | null",
  "started_at": "<rfc3339>",
  "ended_at":   "<rfc3339> | null",
  "fields":     { "key": "value", ... },
  "events":     [
    { "message": "...", "fields": {...}, "timestamp": "<rfc3339>" }
  ]
}

Structs§

LogEvent
A single log event embedded in a span.
Span
A tracing span. Persisted as logs/<id>.json.

Functions§

load_all_spans
Load every span from logs/.
log_event
Add a log event to a span.
parse_fields
Parse key=value pairs from a slice of strings.
render_tree
Render a span tree as indented text, starting from roots (or the given span).
span_end
End a span (record ended_at).
span_set_fields
Set key/value fields on an existing span.
span_start
Start a new span, optionally nested under parent_id. Returns the new span’s UUID.