Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support no_std #52

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// Copyright (C) 2019-2023 Daniel Mueller <[email protected]>
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

#![no_std]

extern crate alloc;
extern crate proc_macro;

use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;

use proc_macro::TokenStream;
use proc_macro2::TokenStream as Tokens;

Expand Down Expand Up @@ -199,10 +206,8 @@ fn expand_tracing_init(attribute_args: &AttributeArgs) -> Tokens {
let __internal_event_filter = {
use ::test_log::tracing_subscriber::fmt::format::FmtSpan;

match ::std::env::var_os("RUST_LOG_SPAN_EVENTS") {
match ::core::option_env!("RUST_LOG_SPAN_EVENTS") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should preserve the runtime behavior, at least for std contexts. Can you introduce an std feature and make this conditional?

Some(mut value) => {
value.make_ascii_lowercase();
let value = value.to_str().expect("test-log: RUST_LOG_SPAN_EVENTS must be valid UTF-8");
Comment on lines -204 to -205
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above.

value
.split(",")
.map(|filter| match filter.trim() {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

#![deny(missing_docs)]
#![no_std]

//! A crate providing a replacement #[[macro@test]] attribute that
//! initializes logging and/or tracing infrastructure before running
Expand Down
Loading