Skip to content
File

Blob: src/workerd/server/log-schema.capnp

1.2 KB
1# Copyright (c) 2017-2022 Cloudflare, Inc.
2# Licensed under the Apache 2.0 license found in the LICENSE file or at:
3# https://opensource.org/licenses/Apache-2.0
4 
5@0x9f8a7b6c5d4e3f2a;
6using Cxx = import "/capnp/c++.capnp";
7using Json = import "/capnp/compat/json.capnp";
8 
9$Cxx.namespace("workerd::server::log_schema");
10$Cxx.allowCancellation;
11 
12struct LogEntry {
13 # Structured log entry for workerd JSON logging
14 
15 timestamp @0 :UInt64 $Json.name("timestamp");
16 # Unix timestamp in milliseconds when the log was generated
17 
18 level @1 :LogLevel $Json.name("level");
19 # Severity level of the log message
20 
21 source @2 :Text $Json.name("source");
22 # Source file and line number where the log originated (e.g., "server.c++:123")
23 
24 message @3 :Text $Json.name("message");
25 # The actual log message content
26 
27 contextDepth @4 :UInt32 $Json.name("context_depth");
28 # Context depth for nested operations (optional, only included if > 0)
29 
30 enum LogLevel {
31 debug @0 $Cxx.name("debug_") $Json.name("debug");
32 # in C++, the constant will be DEBUG_ to avoid clashing with the DEBUG macro
33 info @1 $Json.name("info");
34 warning @2 $Json.name("warning");
35 error @3 $Json.name("error");
36 fatal @4 $Json.name("fatal");
37 }
38}