Skip to content

Draft: Switch all uses of the log crate to tracing.

janimo requested to merge janimo/arti:log-to-tracing into main

This changes all uses of log in libraries and arti to the tracing crate. simple_logging is removed from the binary and no log compatibility bridge is set up, but that can be added (back) if necessary (if some dependencies use the log crate only).

With the default settings, the log lines are a bit longer that with log and use colors, notably the timestamp is longer and the originating module is printed (trace = true is set in config):

Aug 20 21:42:21.042 TRACE mio::poll: registering event source with poller: token=Token(0), interests=READABLE | WRITABLE
Aug 20 21:42:22.816 INFO tor_dirmgr: Didn't get usable directory from cache. Aug 20 21:42:30.288 INFO tor_dirmgr::state: The current consensus is fresh until 2021-08-20 17:00:00 UTC, and valid until 2021-08-20 19:00:00 UTC. I've picked 2021-08-20 18:01:41.024513239 UTC as the earliest time to replace it. Aug 20 21:42:30.288 INFO tor_dirmgr: Directory is complete. Aug 20 21:42:30.288 INFO tor_dirmgr: We have enough information to build circuits. Aug 20 21:42:30.288 INFO tor_dirmgr::bootstrap: 1: Downloading a consensus. Aug 20 21:42:30.288 TRACE mio::poll: registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
Aug 20 21:42:30.288 INFO arti::proxy: Listening on 127.0.0.1:9150.

There's no easy runtime log level selection equivalent to the log! macro in tracing, so that instance in tor-circmgr has two separate calls with similar arguments.

Issue #74 (closed)

Edited by janimo

Merge request reports