Files
BitLogger/docs/api/default-library-logger.md
T
Nanaloveyuki 25a6a973d2 πŸ“ Update More API Document
2026-05-20 11:37:49 +08:00

1.7 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
default-library-logger api facade 20260520 Create the default library-facing console logger facade from shared global defaults.
library
facade
default
public

Default-library-logger

Create a LibraryLogger[ConsoleSink] from the current shared default console logger settings. This is the narrow library-facing counterpart to default_logger().

Interface

pub fn default_library_logger() -> LibraryLogger[ConsoleSink] {

output

  • LibraryLogger[ConsoleSink] - Library-facing console logger built from the current shared defaults.

Explanation

Detailed rules explaining key parameters and behaviors

  • This API wraps default_logger() as a library facade.
  • Each call reflects the current shared default minimum level and default target at that moment.
  • The returned value exposes the narrower LibraryLogger surface rather than the full Logger surface.

How to Use

Here are some specific examples provided.

When Need A Default Logger But Want A Narrower Facade

When a library should adopt the shared console defaults without exposing the full logger type:

let logger = default_library_logger()
if logger.is_enabled(Level::Info) {
  logger.info("ready")
}

In this example, the library facade mirrors the current global defaults.

Error Case

e.g.:

  • If the shared default target is empty, the returned logger is still valid.

  • Later changes to shared defaults do not mutate an already-created facade value.

Notes

  1. Use to_logger() if callers need the full sync logger surface.

  2. This helper is useful for library-facing APIs that should stay narrower than Logger.