[tor-bugs] #23881 [Core Tor/Tor]: Implement a way to utilise tor's logging system from Rust code
Tor Bug Tracker & Wiki
blackhole at torproject.org
Mon Nov 20 16:15:49 UTC 2017
#23881: Implement a way to utilise tor's logging system from Rust code
------------------------------+------------------------------------
Reporter: isis | Owner: chelseakomlo
Type: enhancement | Status: assigned
Priority: High | Milestone: Tor: 0.3.3.x-final
Component: Core Tor/Tor | Version:
Severity: Normal | Resolution:
Keywords: rust, rust-pilot | Actual Points:
Parent ID: | Points: 3
Reviewer: | Sponsor:
------------------------------+------------------------------------
Comment (by chelseakomlo):
Replying to [comment:5 nickm]:
> So my first thought is to take this approach:
> * Refactor the C a bit, though, so that there is a tor_log_string()
function taking a severity, domain, and message. It should work the same
as `tor_log(severity, domain, message);`, but instead it should be safe to
call it function with strings containing `%`. (I can write this one if
you want: it will involve refactoring `logv` a little.
This sounds great- I was hesitant to add a bunch of functionality to Rust
just to make it compatible with the existing C api. If you have time to do
this, that would be great! Otherwise I can take a stab at it this week.
> * Expose that function to rust.
> * Write a single rust macro that takes severity, domain, message, and
some format arguments, and uses the `format!` mechanism to generate the
log message.
This is approximately what I have, with the ability to optionally compile
with a no-op implementation (for running tests at the rust module level).
> Optionally afterwards:
> * Expose a view of `log_global_min_severity` to rust, maybe via a
function.
> * Update the rust macro to compare `log_global_min_severity` to the
declared severity, and avoid formatting the message if no logs actually
want it.
This sounds great- we can do this either in this ticket or an enhancement.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23881#comment:6>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list