tracing icon indicating copy to clipboard operation
tracing copied to clipboard

tracing-log: support `no_std`

Open koute opened this issue 2 years ago • 4 comments

This PR adds support for no_std to tracing-log.

I tried to do this as non-intrusively as possible. The biggest issue here was the use of lazy_static! in lib.rs for the Fields, which had to be removed to make it no_std-compatible. I considered various approaches like:

  1. reexporting the vendored lazy_static from tracing-core so that tracing-log can use is (doing that is kind of messy as the macros would have to be renamed, and it is a relatively big purely private extra API to export),

  2. adding yet another copy of lazy_static (seems pretty silly to do),

  3. constifying all of the necessary methods so that lazy_static is not necessary (unfortunately that's not currently possible),

  4. make it possible to construct a Field in a const fn, and just construct those directly instead of going through the FieldSet::field.

The last one seemed like the most minimal and straightforward one to do, so that's what I did. And as a bonus this might generate slightly more efficient code since now it doesn't have to go through lazy_static (although in practice it'll probably make no difference).

(It would be nice to also add a job on the CI which will make sure that tracing-log will stay no_std compatible, although that's kinda out-of-scope of this PR.)

Fixes https://github.com/tokio-rs/tracing/issues/1663

koute avatar Oct 22 '21 06:10 koute

Any update on this one @koute?

bryangarza avatar May 09 '22 20:05 bryangarza

Any update on this one @koute?

Well, it still needs to be reviewed. (:

koute avatar May 12 '22 07:05 koute

@hawkw Need direction on this PR, do we want to merge/do we need additional changes if so?

bryangarza avatar May 23 '22 22:05 bryangarza

Just want to chime in with my support: Thanks for creating this PR. It would be a huge help to me if this issue were resolved. If there's anything a stranger can do to breathe life back into this PR, let me know.

ccbrown avatar Apr 08 '24 21:04 ccbrown