nx_log_jsonl.nx
buildroot/runtime/nx_log_jsonl.nx
about
nx_log_jsonl.nx -- structured JSONL log line emitter.
One line per log entry, JSON-encoded. Consumable by any log
aggregator: Loki / Splunk / Elasticsearch / Datadog / `jq`.
Standard S-class hosting log shape.
Per cardinal feedback-no-third-party-trust-native-or-nothing:
substrate's own log emitter; no logrus, no log4j, no syslog
SDK. Substrate produces JSON; any consumer reads.
Per cardinal feedback-defensive-at-boundaries-trusting-internally:
log values are escaped for JSON safety (string escape per RFC 8259
ยง7) so log-injection attacks via newlines or quotes in user input
are structurally prevented.
One log line shape:
{"ts_ms":12345,"level":"INFO","module":"nx_audit","msg":"hello"}\n
Caller can add k=v fields via nx_log_field_str / _int after
opening the entry + before closing. Fields are encoded inline:
{"ts_ms":1,"level":"WARN","module":"x","msg":"y","retry":3}\n
nx_capability_claims:
needs: [sealed_enum, bounded_buffer, json_string_escape]
provides: [structured_log_emit, log_injection_prevention]
safety: [no_unchecked_deref, no_floating_point, no_syscall,
bounded_iteration, json_value_escape_at_boundary]
verdict: [sealed_enum_4_state_severity + sealed_enum_4_verdict]
license: ORIGINAL
kind: racing_crew_specialist
layer: L3 (algorithm: structured emit)
dependencies 0 imports · 4 importers
imports: none
imported by: nx_audit_server_routed.nxnx_log_jsonl_test.nxnx_wiki_main.nxnx_wiki_routes.nx
structs
| none |
consts
| 37 | const NXL_DEBUG: i64 = 0 |
| 38 | const NXL_INFO: i64 = 1 |
| 39 | const NXL_WARN: i64 = 2 |
| 40 | const NXL_ERROR: i64 = 3 |
| 41 | const NXL_LEVEL_N: i64 = 4 |
| 67 | const NXL_OK: i64 = 0 |
| 68 | const NXL_OOM_BUFFER: i64 = 1 |
| 69 | const NXL_BAD_LEVEL: i64 = 2 |
| 70 | const NXL_BAD_ARG: i64 = 3 |
| 71 | const NXL_VERDICT_N: i64 = 4 |
functions
| 43 | func nxl_level_is_valid(L: i64) -> i64 |
| 49 | func nxl_level_name(L: i64) -> *u8 |
| 57 | func nxl_level_name_len(L: i64) -> i64 |
| 73 | func nxl_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 79 | func nxl_verdict_name(v: i64) -> *u8 |
| 89 | func nxl_put(out: *u8, off: *i64, cap: i64, b: i64) -> i64 |
| 96 | func nxl_put_cstr(out: *u8, off: *i64, cap: i64, s: *u8) -> i64 |
| 106 | func nxl_put_bytes(out: *u8, off: *i64, cap: i64, src: *u8, n: i64) -> i64 |
| 128 | func nxl_put_json_str_bytes(out: *u8, off: *i64, cap: i64, called by 3: nx_log_emit_linenx_log_emit_line_with_strnx_log_emit_line_with_int calls 2: nxl_put_cstrnxl_put |
| 185 | func nxl_put_dec(out: *u8, off: *i64, cap: i64, |
| 215 | func nx_log_emit_line( called by 1: main calls 7: nxl_level_is_validnxl_put_cstrnxl_put_decnxl_put_bytesnxl_level_namenxl_level_name_len+1 |
| 258 | func nx_log_emit_line_with_str( called by 1: main calls 7: nxl_level_is_validnxl_put_cstrnxl_put_decnxl_put_bytesnxl_level_namenxl_level_name_len+1 |
| 314 | func nx_log_emit_line_with_int( |