Skip to content

Commit

Permalink
logging: use tracing for log output, and output to stderr
Browse files Browse the repository at this point in the history
- Replace `structured_logger` with `tracing-subscribers` for log output.
- Add stderr logging, configurable with the --verbose flag, and the
  RUST_LOG environment variable. The former changes the default log
  level to DEBUG and makes print format more verbose, the latter adjusts
  the log level.

Previously, we were using `log` to produce logs, and `structured_logger`
to put them in a file.

For debugging, I want configurable logging to stderr; however,
`structured_logger` does not allow different outputs to have different
formats or log levels.

We begin to use the `tracing` library as well as `log` for the rule
engine in PR conjure-cp#393 due to its better multi-threading support.
`trace_subscriber::fmt`, the `tracing` log writer used in this patch,
automatically intercepts `log` messages. Thus, the logger can now see
messages from both systems, instead of just `log`.

Long term I believe that `tracing` will be a better choice than `log`
and should be used everywhere; however, for now, supporting both in our
log output is sensible.
  • Loading branch information
niklasdewally committed Nov 4, 2024
1 parent 3aa9bcc commit 6d9cec6
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 283 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
coverage
info.json

conjure_oxide_log.json
conjure_oxide/tests/**/*.generated.*
conjure_oxide/tests/**/*.generated-parse.*
conjure_oxide/tests/**/*.generated-rewrite.*
Expand Down
Loading

0 comments on commit 6d9cec6

Please sign in to comment.