rqbit icon indicating copy to clipboard operation
rqbit copied to clipboard

Adds option to emit json structured logs

Open scottopell opened this issue 1 year ago • 3 comments

This introduces two new options that affect logging output, one that turns on json-formatted logs for the log file option and one for the stdout stream.

      --log-json
          Logging to console (ie, stdout) will emit each log record as a json object

          [env: RQBIT_LOG_JSON=]

      --log-file-json
          Log file will contain json-formatted log records

          [env: RQBIT_LOG_FILE_JSON=]

I think I've managed to not change things too much, lmk what you think

scottopell avatar Sep 28 '24 19:09 scottopell

Thanks for the feedback and pointers, I'm moving this back to a draft for now while I fight with tracing_subscriber

scottopell avatar Oct 03 '24 03:10 scottopell

Also please don't change stderr to stdout for logs. If you really need it for some reason, make it a parameter, but keep the current behavior.

ikatson avatar Oct 03 '24 06:10 ikatson

I'm misunderstanding where the stdout log stream(s) are coming from, I'm seeing duplicated logs, some with human and some with json. I guess need to revisit all the branches of the logging recorder and see what I missed

$ cargo run -- --log-format=json server start /tmp/scratch 2&>/dev/null
2024-10-03T15:55:58.558134Z  INFO rqbit: inreased open file limit limit=61440
{"timestamp":"2024-10-03T15:55:58.558237Z","level":"INFO","fields":{"message":"inreased open file limit","limit":61440},"target":"rqbit"}

scottopell avatar Oct 03 '24 15:10 scottopell