Common Types
ComponentLogging.ComponentLogging — Module
ComponentLoggingModule-scoped logging utilities for Julia built on top of the stdlib Logging. This package provides:
- A
ComponentLoggerwith hierarchical rule keys to control log levels per component path, e.g.(:net, :http). - Lightweight functions
clog,clogenabled,clogffor emitting messages and checking if logging is enabled. - Macros
@clog,@clogf,@clogenabledthat capture the caller module/source location for accurate provenance. - Macro
@forward_loggerto generate module-local forwarding methods. - A simple
PlainLoggersink 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")ComponentLogging.ComponentLogger — Type
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 underlyingAbstractLoggerthat actually handles messages.rules: mapping fromNTuple{N,Symbol}toLogLevel. 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.
ComponentLogging.PlainLogger — Type
PlainLogger(; stream=Base.CoreLogging.closed_stream, min_level=Info)A simple AbstractLogger implementation that prints messages without standard prefixes/timestamps, with minimal coloring by level.
stream::IO: target stream; if closed, falls back tostderr.min_level::LogLevel: minimum enabled level for the sink.
Intended for tests, demos, or embedding in custom sinks.
ComponentLogging.set_log_level! — Function
set_log_level!(logger, group, lvl) -> ComponentLoggerSet 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. If lvl is a Bool, it is treated as a simple switch: true sets the rule to Info and false sets it to LogLevel(1) (which disables the default clogenabled(logger, group) check). Updates the internal min cache appropriately.
ComponentLogging.with_min_level — Function
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.