Files
BitLogger/docs/api/global-info.md
T
2026-06-14 14:00:00 +08:00

2.4 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
global-info api global 20260512 Emit an info-level record through the shared default logger shortcut.
global
info
default
public

Global-info

Emit an info-level record through the shared default logger. This is the global convenience wrapper for log(Level::Info, ...).

Interface

pub fn info(message : String, fields~ : Array[Field] = []) -> Unit {}

input

  • message : String - Informational message text.
  • fields : Array[Field] - Optional structured fields attached to the record.

output

  • Unit - No return value. The record is handled through the shared default logger.

Explanation

Detailed rules explaining key parameters and behaviors

  • This helper delegates to default_logger().info(...).
  • Each call therefore reads the current shared default threshold and target at write time instead of holding one long-lived logger value internally.
  • It uses the shared console sink and current default target.
  • Info is the default global threshold unless changed through set_default_min_level(...).
  • This is the simplest entry point for normal app-level informational events.

How to Use

Here are some specific examples provided.

When Emit Simple Global Application Events

When a small app wants direct lifecycle logging:

set_default_target("app")
info("service started")

In this example, the shared default logger emits an informational record under the app target.

If set_default_target(...) or set_default_min_level(...) changes later, future info(...) calls will observe those updated shared defaults automatically.

When Attach Structured Informational Data

When a global info event should include metadata:

info("request completed", fields=[field("status", "200")])

In this example, the global helper still supports structured fields.

Error Case

e.g.:

  • If the shared minimum level is above Info, the record is skipped.

  • If different components need different targets, shared global info logging may become too broad.

Notes

  1. This is the most common global write helper for small applications or scripts.

  2. Future calls pick up later shared-default changes because the helper forwards through a fresh default_logger() each time.

  3. Prefer explicit loggers when the codebase grows beyond one shared logging path.