core.utils.logger

File:

EuljiroWorship/core/utils/logger.py

Author:

Benjamin Jaedon Choi - https://github.com/saintbenjamin

Affiliated Church:

The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]

Address:

The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea

Telephone:

+82-2-2266-3070

E-mail:

euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)

License:

MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.

Provides error and debug logging utilities for EuljiroBible/EuljiroWorship.

This module defines a lightweight logging wrapper around Python’s standard logging module, with the following design goals:

  • Logs are written to disk only when actually needed

  • A single central log file is used across the application

  • Debug logging is enabled conditionally via the DEBUG environment variable

  • Duplicate handlers are avoided to support hot-reload scenarios

The logger is primarily intended for internal error reporting and optional debug tracing, not for verbose application logging.

core.utils.logger._ensure_file_handler()[source]

Ensure that a file handler is attached to the global logger.

This function lazily initializes a logging.FileHandler and attaches it to the module-level logger only once.

The log file is created only when an error or debug message is actually emitted, avoiding unnecessary file I/O during normal execution.

Returns:

None

core.utils.logger.log_error(e)[source]

Log an exception as an error with full traceback information.

This function ensures that the file handler is initialized, then records the exception message along with its traceback using ERROR log level.

The log file is created only when this function is called.

Parameters:

e (Exception) – The exception instance to be logged.

Returns:

None

core.utils.logger.log_debug(msg)[source]

Log a debug message if DEBUG mode is enabled.

Debug mode is determined by the environment variable DEBUG=1 at application startup. If DEBUG mode is disabled, this function performs no action.

Parameters:

msg (str) – The debug message to record.

Returns:

None