Module logging

Source
Expand description

§Sets up logging by reading configuration from environment variables.

Environment variables used:

  • LOG_MODE: “stdout” (default) or “file”
  • LOG_LEVEL: log level (“trace”, “debug”, “info”, “warn”, “error”); default is “info”
  • LOG_DATA_DIR: directory for log files; default is “logs/”
  • LOG_MAX_SIZE: maximum size of log files in bytes; default is 1GB
  • IN_DOCKER: “true” if running in Docker; default is “false”

Modules§

error
Error handling utilities for the application.

Functions§

compute_rolled_file_path
Computes the path of the rolled log file given the base file path and the date string.
setup_logging
Sets up logging by reading configuration from environment variables.
space_based_rolling
Checks if the given log file exceeds the maximum allowed size (in bytes). If so, it appends a sequence number to generate a new file name. Returns the final log file path to use.