Package-level declarations
The main package of devlog-kotlin
, providing the Logger
API.
The main package of devlog-kotlin
, providing the Logger
API.
Types
Exception that carries log fields, to provide structured logging context when the exception is logged. When passing a cause
exception to one of the methods on Logger, it will check if the given exception is an instance of this class, and if it is, these fields will be added to the log.
Interface for exceptions that carry log fields, to provide structured logging context when an exception is logged. When passing a cause
exception to one of the methods on Logger, it will check if the given exception implements this interface, and if it does, these fields will be added to the log.
Class used in the logging methods on Logger, allowing you to add structured key-value data to the log by calling the field and rawJsonField methods.
A logger provides methods for logging at various log levels (info, warn, error, debug and trace). It has a logger name, typically the same as the class that the logger is attached to (e.g. com.example.Example
). The name is included in the log output, and can be used to enable/disable log levels for loggers based on their package names, or query for logs from a specific class.
Wraps a platform-specific representation of the thread-local logging context fields. On the JVM, this uses SLF4J's MDC context map.
rawJson returns this wrapper around a given raw JSON string, controlling how the JSON string is serialized:
Functions
Returns a copy of the log fields in the current thread's logging context (from withLoggingContext). This can be used to pass logging context between threads (see example below).
Wraps an ExecutorService in a new implementation that copies logging context fields (from withLoggingContext) from the parent thread to child threads when spawning new tasks. This is useful when you use an ExecutorService
in the scope of a logging context, and you want the fields from the logging context to also be included on the logs in the child tasks.
Adds the fields from an existing logging context to all logs made by a Logger in the context of the given block. This overload is designed to be used with getCopyOfLoggingContext, to pass logging context between threads. If you want to add fields to the current thread's logging context, you should instead construct log fields with the field/rawJsonField functions, and pass them to one of the withLoggingContext overloads that take LogFields.
Adds the given log fields to every log made by a Logger in the context of the given block.