You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ Julia’s `CoreLogging` module provides a solid foundation, and this package bui
21
21
- High performance; negligible overhead when logging is disabled. See [Benchmarking](@ref).
22
22
- Suited for controlling module‑wide output granularity using one (or a few) loggers.
23
23
- Enables control‑flow changes based on hierarchical log levels to eliminate unnecessary computations from hot paths.
24
+
-`@forward_logger` macro for ergonomic, module-local forwarding wrappers.
24
25
25
26
## Installation
26
27
@@ -49,7 +50,7 @@ Typically you pass a `ComponentLogger` configured with per-group rules and a sin
49
50
* General rule: `n → LogLevel(n)`.
50
51
* Passing `LogLevel` values (e.g. `Info`) is also supported and equivalent.
51
52
52
-
> **Why logger-first? Performance & type-stability.**No `global_logger()`: `clog`/`clogenabled`/`clogf` take an `AbstractLogger` as the first parameter, which also keeps behavior predictable under concurrency.
53
+
> **Why logger-first? Performance & type-stability.**The stdlib logging macros (`@info`, `@logmsg`, …) typically start by looking up the current logger (task-local, with a global fallback). When you already have a logger (e.g. stored in a `const` or a `Ref`), calling `clog(logger, ...)` bypasses that lookup and can reduce overhead in hot paths, while keeping behavior explicit and predictable under concurrency.
53
54
54
55
**`clog` — emit a log record for a group at a given level**
55
56
@@ -114,11 +115,17 @@ ComponentLogger
114
115
115
116
**Forwarding helpers (recommended)** — ergonomic short paths used throughout your codebase
116
117
118
+
```julia
119
+
@forward_logger clogger
120
+
```
121
+
122
+
The macro above is equivalent to defining the following forwarding methods at module top-level (shown here for clarity):
Copy file name to clipboardExpand all lines: docs/src/functions.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,12 @@ This page documents the **function-first** logging APIs exported by `ComponentLo
8
8
All functions require the logger to be passed explicitly as the first argument.
9
9
In application code you will typically define *forwarding helpers* to avoid threading the logger manually.
10
10
11
+
When you already have a logger available (e.g. stored in a `const` or a `Ref`), calling `clog(logger, ...)` bypasses the task-local logger lookup performed by stdlib logging macros (`@info`, `@logmsg`, …) and can reduce overhead in hot paths.
12
+
13
+
## Forwarding macro
14
+
15
+
`@forward_logger` generates module-local forwarding methods (`clog`, `clogenabled`, `clogf`, `set_log_level!`, `with_min_level`) so you can call them without explicitly passing a logger at every call site.
16
+
11
17
!!! info
12
18
The function APIs do not automatically pass the current module, file, or line information; you need to provide them manually if needed. In the example below, the current module, file, and line are explicitly passed at the call site.
13
19
@@ -19,4 +25,5 @@ In application code you will typically define *forwarding helpers* to avoid thre
0 commit comments