It is useful to be able to emit logs with more detailed information, see e.g. #2. In particular, I think it'd be nice if I could write something like:
let log = oslog::OsLog::new(c"com.example.foo", c"my_category");
oslog::warn!(&log, "User number %i's password %{private}s", 1234, c"password");
And have that be equivalent to the following in C:
os_log_t log = os_log_create("com.example.foo", "my_category");
os_log_warn(log, "User number %i's password %{private}s", 1234, "password");
If nothing else, implementing the C macros in Rust would allow us to avoid the need for a build script, which should make cross-compiling easier. On top of this, we can then implement the oslog::Logger for the log framework, or tracing-oslog could use it to implement the things they need.
Basically, I'm suggesting taking this implementation which allows using os/log.h directly in Rust, and combining it with checks in printf-wrap to make a safe macro with printf-like semantics. I'd also want to add support for activities and signposts.
The difficulty in the implementation this is that the format string must be placed in a special global static (__oslogstring). Swift also special-cases this. So integration with crates like log or tracing will still have to go through extra indirection and a call like "%{public}s".
Would you accept a PR that implements something like this?
I'd also be interested in co-maintaining the crate if you need it (especially if I'm gonna rewrite a large part of it).
It is useful to be able to emit logs with more detailed information, see e.g. #2. In particular, I think it'd be nice if I could write something like:
And have that be equivalent to the following in C:
If nothing else, implementing the C macros in Rust would allow us to avoid the need for a build script, which should make cross-compiling easier. On top of this, we can then implement the
oslog::Loggerfor thelogframework, ortracing-oslogcould use it to implement the things they need.Basically, I'm suggesting taking this implementation which allows using
os/log.hdirectly in Rust, and combining it with checks inprintf-wrapto make a safe macro withprintf-like semantics. I'd also want to add support for activities and signposts.The difficulty in the implementation this is that the format string must be placed in a special global static (
__oslogstring). Swift also special-cases this. So integration with crates likelogortracingwill still have to go through extra indirection and a call like"%{public}s".Would you accept a PR that implements something like this?
I'd also be interested in co-maintaining the crate if you need it (especially if I'm gonna rewrite a large part of it).