|
8 | 8 | - [`GOLOG_LOG_FMT`](#golog_log_fmt) |
9 | 9 | - [`GOLOG_FILE`](#golog_file) |
10 | 10 | - [`GOLOG_OUTPUT`](#golog_output) |
| 11 | + - [`GOLOG_LOG_LABELS`](#golog_log_labels) |
| 12 | + - [`GOLOG_CAPTURE_DEFAULT_SLOG`](#golog_capture_default_slog) |
11 | 13 | - [`GOLOG_TRACING_FILE`](#golog_tracing_file) |
12 | 14 | - [`IPFS_FUSE_DEBUG`](#ipfs_fuse_debug) |
13 | 15 | - [`YAMUX_DEBUG`](#yamux_debug) |
@@ -100,6 +102,60 @@ When stderr and/or stdout options are configured or specified by the `GOLOG_OUTP |
100 | 102 | - `GOLOG_OUTPUT="stdout"` logs only to stdout |
101 | 103 | - `GOLOG_OUTPUT="stderr+stdout"` logs to both stderr and stdout |
102 | 104 |
|
| 105 | +## `GOLOG_LOG_LABELS` |
| 106 | + |
| 107 | +Adds static key-value labels to all log entries. Labels are specified as comma-separated `key=value` pairs. |
| 108 | + |
| 109 | +This is useful for: |
| 110 | +- Identifying logs from different instances in aggregated logging systems |
| 111 | +- Adding deployment context (datacenter, environment, version) |
| 112 | +- Correlating logs across distributed systems |
| 113 | + |
| 114 | +Example: |
| 115 | + |
| 116 | +```console |
| 117 | +export GOLOG_LOG_LABELS="app=kubo,dc=us-west-1,instance=node-42" |
| 118 | +ipfs daemon |
| 119 | +``` |
| 120 | + |
| 121 | +Each log entry will include these labels in JSON format: |
| 122 | + |
| 123 | +```json |
| 124 | +{ |
| 125 | + "level": "info", |
| 126 | + "ts": "2025-01-05T10:30:00.000Z", |
| 127 | + "logger": "core", |
| 128 | + "msg": "daemon started", |
| 129 | + "app": "kubo", |
| 130 | + "dc": "us-west-1", |
| 131 | + "instance": "node-42" |
| 132 | +} |
| 133 | +``` |
| 134 | + |
| 135 | +## `GOLOG_CAPTURE_DEFAULT_SLOG` |
| 136 | + |
| 137 | +Controls whether go-log installs its bridge as Go's default slog handler via `slog.SetDefault()`. |
| 138 | + |
| 139 | +When enabled (default), go-log captures logs from: |
| 140 | +- Go standard library packages using `log/slog` |
| 141 | +- Third-party libraries using `log/slog` |
| 142 | +- go-libp2p (which uses slog internally via gologshim) |
| 143 | + |
| 144 | +This allows unified log management where `ipfs log level` commands control both Kubo subsystems and go-libp2p loggers. |
| 145 | + |
| 146 | +To disable the slog bridge: |
| 147 | + |
| 148 | +```console |
| 149 | +export GOLOG_CAPTURE_DEFAULT_SLOG="false" |
| 150 | +ipfs daemon |
| 151 | +``` |
| 152 | + |
| 153 | +When disabled, only native go-log loggers will be captured. Libraries using `log/slog` directly will use Go's default handler and won't appear in `ipfs log tail` or respond to `ipfs log level` commands. |
| 154 | + |
| 155 | +Default: `true` (enabled) |
| 156 | + |
| 157 | +For more details, see [go-log's slog integration documentation](https://github.com/ipfs/go-log/blob/master/README.md#slog-integration). |
| 158 | + |
103 | 159 | ## `GOLOG_TRACING_FILE` |
104 | 160 |
|
105 | 161 | Sets the file to which Kubo sends tracing events. By default, tracing is |
|
0 commit comments