From 1b78538e4daa534425a1f6bdfc139f9150077fef Mon Sep 17 00:00:00 2001 From: tison Date: Tue, 1 Dec 2026 23:15:35 +0800 Subject: [PATCH] feat(bridge-log): re-export log crate at crate root Add `pub extern crate log;` in `logforth-bridge-log` so downstream callers configuring `LogBridge` or `log::LevelFilter` do not need a separate Cargo dependency solely to name `log` types. Signed-off-by: tison --- CHANGELOG.md | 2 +- bridges/log/README.md | 2 ++ bridges/log/src/lib.rs | 5 +++++ tests-integration/tests/bridge_test/log.rs | 5 ++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 834db98..b519c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,7 +66,7 @@ All significant changes to this project will be documented in this file. * Add `Error::message` and `RecordBuilder::time` in `logforth-core` to borrow an error's own message string and construct records with an explicit observed timestamp. * Make `Logger` a pointer-sized `Clone` and `Default` handle over a shared pipeline, add `const fn Logger::noop()`, `LoggerBuilder::new()` and `RecordBuilder::new()` (with `Default`), `const fn new()` on `PlainTextLayout`, `ThreadLocalDiagnostic`, `StderrErrorSink`, and `BlackHoleErrorSink`, and `new()` on `Stdout`, `Stderr`, and `Testing` in `logforth-core`, add `const fn new()` on `TaskLocalDiagnostic` in `logforth-diagnostic-task-local`, `FastraceDiagnostic` in `logforth-diagnostic-fastrace`, `FastraceEvent` in `logforth-append-fastrace`, and `GoogleCloudLoggingLayout` in `logforth-layout-google-cloud-logging`, add `new()` on `TextLayout`, `LogfmtLayout`, and `JsonLayout`, and implement `Clone`, `Default`, and `From` for `LogBridge` in `logforth-bridge-log`. * Add `Level::ALL` in `logforth-core` and `ValueOwned::{from_serde, try_from_serde}` (behind the `serde` feature) to convert `serde::Serialize` values into structured `ValueOwned` trees without panicking. -* Add `LogBridge::{max_level, logger, into_logger, try_install, install}` in `logforth-bridge-log`, and add `starter_log::{LogStarterExt, LogStarter::try_build}` (with `Debug` for `LogStarter`), `layout::{json, logfmt}` module re-exports, and the `serde` feature (`logforth-core/serde`) in `logforth`, updating `log::set_max_level` automatically from enabled logger levels on installation. +* Add `LogBridge::{max_level, logger, into_logger, try_install, install}` in `logforth-bridge-log` (re-exporting `log`), and add `starter_log::{LogStarterExt, LogStarter::try_build}` (with `Debug` for `LogStarter`), `layout::{json, logfmt}` module re-exports, and the `serde` feature (`logforth-core/serde`) in `logforth`, updating `log::set_max_level` automatically from enabled logger levels on installation. * Add `LoggerBuilder::error_sink` and `starter_log::LogStarter::error_sink` to configure runtime error handling. * Implement `Append`, `ErrorSink`, `Filter`, and `Layout` in `logforth-core`, and `MakeBody` in `logforth-append-opentelemetry`, for `Arc` and `&'static T` where `T: ?Sized`, and implement `Diagnostic` for `&T`, `Arc`, `()`, `Option`, slices, arrays, and `Vec` (including non-`'static` boxed trait objects). * Add `FileBuilder::timezone` in `logforth-append-file` (and re-export `jiff`) to configure the timezone used for rotation boundaries and segment filenames, defaulting to the system timezone. diff --git a/bridges/log/README.md b/bridges/log/README.md index 03f8995..2aee9ce 100644 --- a/bridges/log/README.md +++ b/bridges/log/README.md @@ -46,6 +46,8 @@ fn main() -> Result<(), logforth_core::Error> { When routing individual call sites with `log::info!(logger: bridge, ...)` without installing a global logger, ensure the process-wide `log::max_level()` ceiling (which defaults to `Off`) covers the bridge's active levels via `log::set_max_level(log::max_level().max(bridge.max_level()))`. +`log` is re-exported at `logforth_bridge_log::log` so callers do not need a direct Cargo dependency solely to name `log::LevelFilter` or related types. + ## Mapping semantics Each `log::Level` maps 1-to-1 to the corresponding `logforth_core::record::Level`: diff --git a/bridges/log/src/lib.rs b/bridges/log/src/lib.rs index d90c982..3c35ca6 100644 --- a/bridges/log/src/lib.rs +++ b/bridges/log/src/lib.rs @@ -29,6 +29,9 @@ //! without the `logforth` facade, or when passing an explicit [`LogBridge`] to //! `log::info!(logger: bridge, ...)`. //! +//! The crate re-exports `log` at `logforth_bridge_log::log`, so callers can use +//! [`log::LevelFilter`] and related types without adding a separate dependency. +//! //! [`logforth::starter_log`]: https://docs.rs/logforth/0.31.0/logforth/starter_log/index.html //! //! # Mapping semantics @@ -69,6 +72,8 @@ //! process-wide [`log::max_level()`] (default `Off`), for example with //! `log::set_max_level(log::max_level().max(bridge.max_level()))`. +pub extern crate log; + use log::Metadata; use log::Record; use logforth_core::Error; diff --git a/tests-integration/tests/bridge_test/log.rs b/tests-integration/tests/bridge_test/log.rs index f57fb03..add0bb9 100644 --- a/tests-integration/tests/bridge_test/log.rs +++ b/tests-integration/tests/bridge_test/log.rs @@ -52,7 +52,10 @@ fn max_level_accessors_enabled_and_flush() { } let noop = LogBridge::default(); - assert_eq!(noop.max_level(), log::LevelFilter::Off); + assert_eq!( + noop.max_level(), + logforth::bridge::log::log::LevelFilter::Off + ); assert!(!noop.logger().enabled(Level::Error)); for (filter, expected) in [ (LevelFilter::Equal(Level::Fatal), log::LevelFilter::Off),