Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Logger>` 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<T>` and `&'static T` where `T: ?Sized`, and implement `Diagnostic` for `&T`, `Arc<T>`, `()`, `Option<T>`, 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.
Expand Down
2 changes: 2 additions & 0 deletions bridges/log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
5 changes: 5 additions & 0 deletions bridges/log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion tests-integration/tests/bridge_test/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading