Skip to content

Commit

Permalink
Log to stderr
Browse files Browse the repository at this point in the history
env_logger was doing it, tracing wasn't. Make sure that both do it.
  • Loading branch information
d-e-s-o committed Jan 5, 2025
1 parent 681d1e1 commit e0854f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2023-2024 Daniel Mueller <[email protected]>
# Copyright (C) 2023-2025 Daniel Mueller <[email protected]>
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

name: Publish
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
--request POST \
--url https://api.github.com/repos/${{ github.repository }}/releases \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--data "{
\"tag_name\":\"v${version}\",
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ members = ["macros"]

[dependencies]
test-log-macros = {version = "0.2.15", path = "macros"}
tracing-subscriber = {version = "0.3.17", default-features = false, optional = true, features = ["env-filter", "fmt"]}
tracing-subscriber = {version = "0.3.17", default-features = false, optional = true, features = ["env-filter", "fmt"], git = "https://github.com/d-e-s-o/tracing.git", branch = "topic/test-writer-stderr-v0.1.x"}
env_logger = {version = "0.11", default-features = false, optional = true}

[dev-dependencies]
logging = {version = "0.4.8", package = "log"}
test-case = {version = "3.1"}
tokio = {version = "1.0", default-features = false, features = ["rt-multi-thread", "macros"]}
tracing = {version = "0.1.20"}
tracing = {version = "0.1.20", git = "https://github.com/d-e-s-o/tracing.git", branch = "topic/test-writer-stderr-v0.1.x"}

# error: cannot find macro `__lazy_static_internal` in this scope
# --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/sharded-slab-0.1.4/src/tid.rs:33:1
Expand Down
8 changes: 5 additions & 3 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2023 Daniel Mueller <[email protected]>
// Copyright (C) 2019-2025 Daniel Mueller <[email protected]>
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

extern crate proc_macro;
Expand Down Expand Up @@ -167,7 +167,9 @@ fn expand_logging_init(attribute_args: &AttributeArgs) -> Tokens {
{
let mut env_logger_builder = ::test_log::env_logger::builder();
#add_default_log_filter
let _ = env_logger_builder.is_test(true).try_init();
let _ = env_logger_builder
.target(::test_log::env_logger::Target::Stderr)
.is_test(true).try_init();
}
}
}
Expand Down Expand Up @@ -226,7 +228,7 @@ fn expand_tracing_init(attribute_args: &AttributeArgs) -> Tokens {
let _ = ::test_log::tracing_subscriber::FmtSubscriber::builder()
.with_env_filter(#env_filter)
.with_span_events(__internal_event_filter)
.with_test_writer()
.with_writer(::test_log::tracing_subscriber::fmt::TestWriter::with_stderr)
.try_init();
}
}
Expand Down

0 comments on commit e0854f3

Please sign in to comment.