This page covers the most common runtime errors developers encounter when using Chromologger, along with their root causes and step-by-step fixes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Dev2Forge/chromologger/llms.txt
Use this file to discover all available pages before exploring further.
FileNotFoundError when creating a Logger
FileNotFoundError when creating a Logger
Cause: The parent directory of the log file path you passed to Fix: Create the directory with
Logger() does not exist. Chromologger opens the file with FileManager.open_file() and does not auto-create missing parent directories — it only creates the file itself.os.makedirs before instantiating the logger.When you use the default
Logger() (i.e. log_file_name='log.log'), the file is placed in the same directory as your calling script — a directory that always exists. You do not need os.makedirs for the default case.Logger.close() returns False
Logger.close() returns False
Cause: Fix: Resolve the underlying cause (missing directory or insufficient permissions) so that
Logger.__open() returned -1 (an int) because the log file could not be opened — typically due to a missing directory or a permission error. The close() method checks type(self.file) == TextIOWrapper before attempting to close; when self.file is -1, it skips the close and returns False.How to detect it before calling close():__open() succeeds and self.file is a valid TextIOWrapper.ModuleNotFoundError: No module named 'chromolog'
ModuleNotFoundError: No module named 'chromolog'
Cause: Chromologger depends on
chromolog==0.2.5 for colorized console output (via chromolog.Print). If chromolog is missing, Python raises ModuleNotFoundError the moment chromologger is imported.Fix: Install the missing dependency manually.chromolog==0.2.5 is listed as a dependency in Chromologger’s pyproject.toml, so running pip install chromologger should install it automatically. If it did not (e.g. you installed from source or a custom wheel), the command above resolves it.Log entries not appearing in the file
Log entries not appearing in the file
This symptom has two common causes.Cause 1 — File never opened: If
Logger.__open() returned -1, every call to log() or log_e() reaches the internal __write() method, which tries to call self.file.writelines(...) on an integer. The resulting AttributeError is caught silently by __write’s internal error handler and written to the module’s own log.log — not your file.Cause 2 — Logger not closed: Without calling logger.close(), buffered content may not be fully flushed to disk. Although Chromologger uses writelines (which generally flushes line-by-line), explicitly closing the file is still strongly recommended.Fix:Wrong log file location
Wrong log file location
Cause: When you call If your script lives in
Logger() with the default log_file_name='log.log', Chromologger places the file beside the calling script — not the current working directory. It determines the script’s location at runtime using:/home/user/myproject/src/app.py but you run Python from /home/user/myproject/, the log file appears in src/, which can be surprising.Fix: Pass an explicit path to Logger() so the location is always predictable.