class
Logit::Formatter::JSON
- Logit::Formatter::JSON
- Logit::Formatter
- Reference
- Object
Overview
JSON formatter for structured log output.
Produces newline-delimited JSON (NDJSON) output suitable for log aggregation systems like Elasticsearch, Datadog, or Splunk.
The JSON structure follows OpenTelemetry conventions:
{
"trace_id": "abc123...",
"span_id": "def456...",
"parent_span_id": "ghi789...",
"timestamp": "2024-01-15T10:30:00.000000Z",
"duration_ms": 42,
"name": "find_user",
"level": "info",
"status": "ok",
"code": {
"file": "user_service.cr",
"line": 15,
"function": "find_user",
"namespace": "UserService"
},
"attributes": {
"code.arguments": {"id": 42},
"code.return": "User{id: 42}"
}
}
Defined in:
logit/formatters/json.crInstance Method Summary
-
#format(event : Event) : String
Formats an event as a JSON string.