Logging System

The RxInfer Server uses a logging system that divides logs by functional groups and stores them in separate files.

Configuration

For logging configuration options, see Logging Configuration in the main configuration documentation.

Architecture

The logging functionality is encapsulated in the Logging module (src/logging.jl), which:

  • Uses a TeeLogger to output logs to multiple destinations simultaneously
  • Groups logs by their functional component
  • Maintains separate log files for each tag/group (e.g., Server.log, Authentification.log)

Usage

The Logging.with_logger function is the primary API:

Logging.with_logger() do
    @info "This message will be logged to both terminal and files"
end

Log Groups

Log groups are automatically derived from the file basename. For example:

  • Messages from src/tags/Server.jl belong to the :Server group
  • Messages from src/tags/Authentification.jl belong to the :Authentification group
  • Messages from src/tags/Models.jl belong to the :Models group

The system routes logs to the appropriate files based on these groups without requiring explicit group specification.

API Reference

RxInferServer.Logging.with_loggerFunction
with_logger(f)

Sets up the logging system and executes the provided function with the configured logger. Creates a TeeLogger that writes to:

  1. Terminal with human-readable formatting
  2. A main log file (.log) with all messages
  3. Separate files for each functional group (Server.log, Authentification.log, etc.)
  4. A debug log file (debug.log) if debug logging is enabled, see RxInferServer.Logging.RXINFER_SERVER_ENABLE_DEBUG_LOGGING

Arguments

  • f: The function to execute with the configured logger

Examples

Logging.with_logger() do
    @info "This message will be logged to both terminal and files"
end

Returns

  • The return value of the provided function
source
RxInferServer.Logging.with_simple_loggerFunction
with_simple_logger(f, io::IO)

Sets up the logging system and executes the provided function with the configured logger. Creates a SimpleLogger that writes to the specified IO stream.

Arguments

  • f: The function to execute with the configured logger
  • io: The IO stream to write the logs to

Returns

  • The return value of the provided function
source
RxInferServer.Logging.filter_by_groupFunction
filter_by_group(group)

Creates a logger filter function that only allows log messages with the specified group tag. Used to separate logs into different files by their functionality/module.

Arguments

  • group: The symbol representing a log group (e.g., :Server, :Authentification)

Returns

  • A function that takes a logger and returns an EarlyFilteredLogger that filters by the specified group
source
RxInferServer.Logging.filter_by_moduleFunction
filter_by_module(_module)

Creates a logger filter function that only allows log messages from the specified module. Used to separate logs by their source module. Uses occursin to match the module name.

Arguments

  • _module: The module name to filter by (e.g., "RxInferServer"), must be a string

Returns

  • A function that takes a logger and returns an EarlyFilteredLogger that filters by the specified module
source
RxInferServer.Logging.filter_by_levelFunction
filter_by_level(level_range)

Creates a logger filter function that only allows log messages within the specified range of log levels. Used to separate logs by their severity level.

Arguments

  • level_range: A range of log levels to include

Returns

  • A function that takes a logger and returns an EarlyFilteredLogger that filters by the specified level range
source

Adding New OpenAPI Tags

When adding new tags to the OpenAPI schema:

  1. Create a new file in the src/tags/ directory (e.g., NewTag.jl)
  2. Add a corresponding logger in the Logging.with_logger function:
# In src/logging.jl:
MiniLoggers.MiniLogger(; io = joinpath(RXINFER_SERVER_LOGS_LOCATION, "NewTag.log"), kwargs_logger...) |> filter_by_group(:NewTag)

This ensures logs from the new tag will be properly captured in a dedicated log file.