From e0854f316c88c49c2a39bf0625980f69a81dc2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sun, 5 Jan 2025 13:55:01 -0800 Subject: [PATCH] Log to stderr env_logger was doing it, tracing wasn't. Make sure that both do it. --- .github/workflows/publish.yml | 4 ++-- Cargo.toml | 4 ++-- macros/src/lib.rs | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c51b47b..9072841 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -# Copyright (C) 2023-2024 Daniel Mueller +# Copyright (C) 2023-2025 Daniel Mueller # SPDX-License-Identifier: (Apache-2.0 OR MIT) name: Publish @@ -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}\", diff --git a/Cargo.toml b/Cargo.toml index 6e78b25..4a1cead 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c78f9e6..ea3e179 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2023 Daniel Mueller +// Copyright (C) 2019-2025 Daniel Mueller // SPDX-License-Identifier: (Apache-2.0 OR MIT) extern crate proc_macro; @@ -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(); } } } @@ -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(); } }