rqbit
rqbit copied to clipboard
Adds option to emit json structured logs
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
Thanks for the feedback and pointers, I'm moving this back to a draft for now while I fight with tracing_subscriber
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.
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"}