Logging

The Codesealer Workers produce various useful log messages during operation such as information about each request. By default logs are output in JSON format. During debugging it may be desirable to produce more human readable logs, in which case the -h flag can be passed to the Worker.

Log format

Codesealer's request logs have the following JSON structure. Note that some fields are optional.

{
  // The log level.
  "level": "info",

  // When the request was logged.
  "time": "2023-10-18T14:03:20.179951572+02:00",

  // The type of the request. One of:
  //   "proxy",
  //   "bootloader", "appscript", "keyexchange", "handshake"
  //   "anp", "mobile", "websocket"
  "type": "anp",

  // (Optional) The ID of the request, if this was an ANP request.
  "reqID": "2e62f9d0323a37e8",

  // The IP that made the request.
  "remote": "1.2.3.4:56",

  // (Optional) Whether the response was fetched from the Worker's cache.
  "cached": true,

  // (Optional) Whether this request was flagged as suspicious.
  "flagged": false,

  // (Optional) Whether this request was throttled by the Worker.
  "throttled": true,

  // Information about the request the Worker received.
  "reqIn": {
    "Addr": "4.3.2.1:443",
    "URL": "https://domain.org/~bl/x/",
    "Host": "domain.org:443",
    "SNI": "domain.org",
    "Method": "POST"
  },

  // (Optional) Information about the proxied request the Worker sent.
  "reqOut": {
    "Addr": "backend.domain.org:443",
    "URL": "https://backend.domain.org/scripts/main.js",
    "Host": "backend.domain.org",
    "SNI": "backend.domain.org",
    "Method": "GET",
    "Status": "200 OK",
    "ContentLength": "42",
    "ForwardedFor": "1.2.3.4:56"
  },

  // (Optional) The time it took the backend to respond to the Worker's request.
  "remoteTime": "1.7ms",

  // (Optional) The total time it took the Worker to process the request.
  "totalTime": "1.4ms",

  // A messaged attach to this log line.
  "message": "request completed"
}