Common Types

ComponentLogging.ComponentLoggingModule
ComponentLogging

Component-scoped logging utilities for Julia built on top of Logging. This package provides:

  • A ComponentLogger with hierarchical rule keys to control log levels per component path, e.g. (:net, :http).
  • Lightweight functions clog, clogenabled, clogf for emitting messages and checking if logging is enabled.
  • Macros @clog, @clogf, @clogenabled that capture the caller module/source location for accurate provenance.
  • A simple PlainLogger sink for pretty, colored output without timestamps/prefixes.

Typical usage:

using ComponentLogging

rules = Dict(
    :core => Info, 
    :io => Warn, 
    :net => Debug
)
clogger = ComponentLogger(rules; sink=PlainLogger())

clog(clogger, :core, Info, "something happened")
source
ComponentLogging.ComponentLoggerType
ComponentLogger(; sink=ConsoleLogger(Debug))
ComponentLogger(rules::AbstractDict; sink=ConsoleLogger(Debug))

A logger that delegates to an underlying sink (AbstractLogger) while applying component-based minimum level rules. Rules are defined on paths of symbols (NTuple{N,Symbol}). A lookup walks up the path and falls back to (:__default__,).

  • sink: the underlying AbstractLogger that actually handles messages.
  • rules: mapping from NTuple{N,Symbol} to LogLevel. The default entry ((DEFAULT_SYM,), Info) is created automatically when needed.

The effective minimum level is the minimum of all values in rules, cached in the min field for fast checks.

source
ComponentLogging.PlainLoggerType
PlainLogger(stream::IO, min_level::LogLevel=Info)
PlainLogger(min_level::LogLevel=Info)

A simple AbstractLogger implementation that prints messages without standard prefixes/timestamps, with minimal coloring by level.

  • stream: target stream; if closed, falls back to stderr.
  • min_level: minimum enabled level for the sink.

Intended for tests, demos, or embedding in custom sinks.

source
ComponentLogging.set_log_level!Function
set_log_level!(logger, group, lvl) -> ComponentLogger

Set or update the minimum level for a specific component group on logger. group may be a Symbol or a NTuple{N,Symbol} tuple; lvl can be LogLevel or Integer. Updates the internal min cache appropriately.

source
ComponentLogging.with_min_levelFunction
with_min_level(f, logger, lvl)

Temporarily set logger.min to lvl while executing f(), restoring the original value afterward even if an exception is thrown.

source