Skip to content

Commit

Permalink
docs: Added details to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
curtd committed May 28, 2023
1 parent cdee20d commit 4e2fc63
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,24 @@
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://curtd.github.io/LoggingCommon.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://curtd.github.io/LoggingCommon.jl/dev/)
[![Build Status](https://github.com/curtd/LoggingCommon.jl/actions/workflows/CI.yml/badge.svg?branch=main)](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.
2 changes: 1 addition & 1 deletion src/records.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ struct StacktraceLogRecord <: AbstractLogRecord
stacktrace::Base.StackTraces.StackTrace
end

stacktrace_log_record(static_meta::StaticLogRecordMetadata, stacktrace::Base.StackTraces.StackTrace, args...; exception::Union{Nothing,Exception}=nothing, kwargs...) = LogRecord(static_meta, StacktraceLogRecord(exception, stacktrace), args...; kwargs...)
stacktrace_log_record(static_meta::StaticLogRecordMetadata, stacktrace::Base.StackTraces.StackTrace, args...; exception::Union{Nothing,Exception}=nothing, kwargs...) = LogRecord(static_meta, StacktraceLogRecord(exception, stacktrace), args...; kwargs...)

stacktrace_log_record(static_meta::StaticLogRecordMetadata, bt::Vector, args...; kwargs...) = stacktrace_log_record(static_meta, stacktrace(bt), args...; kwargs...)

Expand Down

0 comments on commit 4e2fc63

Please sign in to comment.