Name the warning level `warn` in structured logs #7045
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 506 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.373
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7045"
general
weight: 0.35
mar-cf
Problem
workerd emits structured JSON logs from two places, with two different sets of level names:
| Producer | Level names |
| --- | --- |
| JS console logs —
logLevelToString()inio/worker.c++, viaformatLog()insrc/node/internal/internal_inspect.ts|debuginfologwarnerror|| Process-level logs —
context.warning()/KJ_LOG, vialog-schema.capnpinserver/json-logger.c++|debuginfowarningerrorfatal|debug,infoanderroragree.warningwas the lone outlier, so a consumer keying onwarnpicks up a Worker's
console.warn()but silently demotes workerd's own warnings to whatever it doeswith unrecognised levels:
defaultStructuredLogsHandlertestslevel === "error" || level === "warn", so aprocess warning goes to
console.loginstead of redconsole.error.handleStructuredLogstestswarn/info/debug/errorand falls through tologger.log, which is below thewarnthreshold — so--log-level=warnhides warnings entirely.warn/errorand falls through tologger.info.Change
Spell the level
warnon the wire. The Cap'n Proto enumerant keeps mirroringkj::LogSeverity::WARNING; only the$Json.nameannotation changes, so no C++ is affected —capnp'sAnnotatedEnumHandlerapplies the annotation to both encode and decode, andjson-logger.c++already installs it viahandleByAnnotation.This fixes already-released wrangler, Vite plugin and Miniflare versions on the next workerd
bump, with no changes needed on their side.
log-schema.capnpis consumed only byjson-logger.{h,c++}and its test, and lives underserver/, so this doesn't reach the production runtime. No compatibility flag applies: this isprocess-level CLI output, not per-Worker behaviour.
Testing
The level names had no coverage:
json-logger-testdecoded each entry with the same annotated codecthat encoded it, which round-trips whatever the schema says. That's why the mismatch went unnoticed.
JSON log level namestest pins the encoded string for all five levels. It needs no capturedfile descriptor, unlike the rest of that file, so it runs on macOS and Windows too — which lets
the file drop its
Blank test because KJ fails when 0 tests are enabledplaceholder."level":"warn"assertion in the existing structured-mode test, so the realcontext.warning()path is pinned rather than just the codec.{"timestamp":"0","level":"warning","context_depth":0}failed theWARNINGcase while
debug/info/error/fatalpassed, confirmingwarningwas the only outlier.workerd serveon a config withstructuredLogging = trueand aredundant compatibility flag (stacking #6980 locally so the diagnostic is a warning rather than a
fatal error):
Noticed, not addressed
log-schema.capnpclaimscontextDepthis "only included if > 0" andbuildJsonLogMessageguards on that, but the codec emits default primitives regardless, so every entry carries
"context_depth":0.sourceon process-level entries is alwaysjson-logger.c++:109or:127— the wrapper's own__FILE__/__LINE__, not the origin. OnlyKJ_LOGentries get a useful value.fatalhas no counterpart in the console vocabulary, so it still lands at plain log level inworkers-sdk. It can't be aliased to
errorhere: duplicate$Json.namevalues would breakAnnotatedEnumHandler, which inserts them into akj::HashMap. That fix belongs on the consumerside, along with optionally accepting
"warning"so older workerd binaries stay correctly levelled.