https://github.com/curtd/loggingcommon.jl
Common types + functions for logging frameworks
https://github.com/curtd/loggingcommon.jl
julia logging
Last synced: 10 months ago
JSON representation
Common types + functions for logging frameworks
- Host: GitHub
- URL: https://github.com/curtd/loggingcommon.jl
- Owner: curtd
- License: mit
- Created: 2023-05-27T18:28:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T18:28:32.000Z (about 2 years ago)
- Last Synced: 2025-08-07T08:34:23.253Z (11 months ago)
- Topics: julia, logging
- Language: Julia
- Homepage:
- Size: 267 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LoggingCommon
[](https://curtd.github.io/LoggingCommon.jl/stable/)
[](https://curtd.github.io/LoggingCommon.jl/dev/)
[](https://github.com/curtd/LoggingCommon.jl/actions/workflows/CI.yml?query=branch%3Amain)
Provides some definitions that are useful as the basis for creating a generic logging framework, slightly extending the types and methods introduced in [`Base.Logging`](https://docs.julialang.org/en/v1/stdlib/Logging/).
## Log Message Levels
This package adds additional log level aliases to the standard ones from `Base.Logging`. In total, the available log levels are (in order) `NotSet`, `All`, `Trace`, `Debug`, `Info`, `Notice`, `Warn`, `Error`, `Critical`, `Alert`, `Emergency`, `Fatal`, `AboveMax`, and `Off`.
These aliases can be represented as a `NamedLogLevel`, which maps a `Symbol` to a particular `Base.LogLevel` via the `log_level` function.
```julia-repl
julia> using LoggingCommon
julia> l = NamedLogLevel(:alert); log_level(l)
LogLevel(2010)
```
## Log Records
The generic `LogRecord` type represents a generic logging record. It contains both the record itself, as well as static + runtime metatdata associated to it. This type can be used in a generic logging framework, such as [`LoggingExtras`](https://github.com/JuliaLogging/LoggingExtras.jl), to format log message outputs without extraneous logging boilerplate.
Message records can be created via `message_log_record`, which associates a single `String` message to a log record. Stacktrace records can be created via `stacktrace_log_record`, which associates a `Base.StackTraces.StackTrace` (and an optional `Exception`) to a log record.
For each log record, there are two types introduced representing metadata-values associated to a particular log record -- `StaticLogRecordMetadata` and `RuntimeLogRecordMetadata`. These types record log message information available at compile time (e.g., originating module, line number, etc., ) and at runtime (e.g., datetime, thread id, distributed worker id), respectively.