Skip to content

refactor!: remove logforth core global logger - #226

Merged
tisonkun merged 5 commits into
mainfrom
no-single-global-logger
May 25, 2026
Merged

refactor!: remove logforth core global logger#226
tisonkun merged 5 commits into
mainfrom
no-single-global-logger

Conversation

@tisonkun

@tisonkuntisonkun commented May 24, 2026

Copy link
Copy Markdown
Contributor

This closes#214

Signed-off-by: tison <wander4096@gmail.com>

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the logforth_core “default/global logger” concept and shifts global log crate integration to explicit logforth-bridge-log adapter types (and logforth’s starter-log feature), updating examples, features, and docs accordingly.

Changes:

  • Removed core-level global logger APIs (default_logger, set_default_logger, LoggerBuilder::{apply, try_apply}) so LoggerBuilder only constructs Logger instances.
  • Refactored the log bridge to expose LogAdapter/OwnedLogAdapter/SharedLogAdapter and removed the previous global setup/try_setup helpers.
  • Updated starter_log to register the log crate’s global logger directly using OwnedLogAdapter, and adjusted examples/docs/features to match the new model.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
logforth/src/starter_log.rsSwitches starter to install the log global logger via OwnedLogAdapter instead of relying on a core default logger.
logforth/src/lib.rsRemoves re-exports of core global logger APIs and gates starter_log behind starter-log.
logforth/Cargo.tomlUpdates starter-log feature to include an optional log dependency.
examples/src/log_with_logger.rsRenames example usage from OwnedLogProxy to OwnedLogAdapter.
examples/src/asynchronous.rsDemonstrates keeping a logger handle (SharedLogAdapter) and registering it with log::set_boxed_logger.
examples/Cargo.tomlAligns example feature wiring with logforth/starter-log and updates required features for examples.
core/src/logger/mod.rsDrops re-exports of the removed global logger APIs.
core/src/logger/log_impl.rsRemoves the OnceLock-backed default logger implementation.
core/src/logger/builder.rsRemoves global-logger setup methods and updates doctests to use build().
CHANGELOG.mdUpdates breaking-change guidance to reflect “keep a logger handle” instead of using default_logger().flush().
bridges/log/src/lib.rsReplaces global setup with explicit adapter types (borrowed/owned/shared) and removes setup/try_setup.
appenders/syslog/src/lib.rsUpdates docs to build a logger without relying on removed global logger APIs.
appenders/syslog/Cargo.tomlRemoves log dev-dependency (previously used by the docs/example path).
appenders/file/src/rolling.rsUpdates rand trait import in tests (RngExt).
appenders/file/src/lib.rsUpdates docs to build a logger without relying on removed global logger APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadappenders/file/src/lib.rs
Comment threadappenders/syslog/src/lib.rs
Comment threadcore/src/logger/builder.rs
@tisonkun
tisonkunforce-pushed the no-single-global-logger branch 2 times, most recently from 0dede20 to 379428fCompareMay 24, 2026 14:48
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
tisonkunforce-pushed the no-single-global-logger branch from 379428f to 3c60104CompareMay 24, 2026 14:51
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
tisonkun requested a review from CopilotMay 25, 2026 03:24
@tisonkun
tisonkun enabled auto-merge (squash) May 25, 2026 03:25
@tisonkun
tisonkun disabled auto-merge May 25, 2026 03:25

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Comment threadcore/src/logger/builder.rs Outdated
Comment threadlogforth/src/starter_log.rs Outdated
Comment threadappenders/syslog/src/lib.rs
Comment threadappenders/file/src/lib.rs
Comment threadlogforth/src/starter_log.rs Outdated
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
tisonkun enabled auto-merge (squash) May 25, 2026 03:33
@tisonkun
tisonkun merged commit 4b1a04f into mainMay 25, 2026
10 checks passed
@tisonkun
tisonkun deleted the no-single-global-logger branch May 25, 2026 03:37
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review global default logger

2 participants

@tisonkun