add labels/env log option for jsonfile
this allows jsonfile logger to collect extra metadata from containers with `--log-opt labels=label1,label2 --log-opt env=env1,env2`. Extra attributes are saved into `attrs` attributes for each log data. Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
This commit is contained in:
parent
5b56e85c9d
commit
154434f5a2
2 changed files with 15 additions and 0 deletions
|
@ -21,6 +21,8 @@ func TestJSONLogsMarshalJSONBuf(t *testing.T) {
|
|||
&JSONLogs{Log: []byte("\u2028 \u2029")}: `^{\"log\":\"\\u2028 \\u2029\",\"time\":}$`,
|
||||
&JSONLogs{Log: []byte{0xaF}}: `^{\"log\":\"\\ufffd\",\"time\":}$`,
|
||||
&JSONLogs{Log: []byte{0x7F}}: `^{\"log\":\"\x7f\",\"time\":}$`,
|
||||
// with raw attributes
|
||||
&JSONLogs{Log: []byte("A log line"), RawAttrs: []byte(`{"hello":"world","value":1234}`)}: `^{\"log\":\"A log line\",\"attrs\":{\"hello\":\"world\",\"value\":1234},\"time\":}$`,
|
||||
}
|
||||
for jsonLog, expression := range logs {
|
||||
var buf bytes.Buffer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue