AppendEncoder can be used to add fields to all log entries that pass through it. It is a wrapper around another encoder, which it uses to actually encode the log entries. It is most useful for adding information about the Caddy instance that is producing the log entries, possibly via an environment
| 42 | // instance that is producing the log entries, possibly via |
| 43 | // an environment variable. |
| 44 | type AppendEncoder struct { |
| 45 | // The underlying encoder that actually encodes the |
| 46 | // log entries. If not specified, defaults to "json", |
| 47 | // unless the output is a terminal, in which case |
| 48 | // it defaults to "console". |
| 49 | WrappedRaw json.RawMessage `json:"wrap,omitempty" caddy:"namespace=caddy.logging.encoders inline_key=format"` |
| 50 | |
| 51 | // A map of field names to their values. The values |
| 52 | // can be global placeholders (e.g. env vars), or constants. |
| 53 | // Note that the encoder does not run as part of an HTTP |
| 54 | // request context, so request placeholders are not available. |
| 55 | Fields map[string]any `json:"fields,omitempty"` |
| 56 | |
| 57 | wrapped zapcore.Encoder |
| 58 | repl *caddy.Replacer |
| 59 | |
| 60 | wrappedIsDefault bool |
| 61 | ctx caddy.Context |
| 62 | } |
| 63 | |
| 64 | // CaddyModule returns the Caddy module information. |
| 65 | func (AppendEncoder) CaddyModule() caddy.ModuleInfo { |
nothing calls this directly
no outgoing calls
no test coverage detected