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.
log_e() is Chromologger’s dedicated method for exceptions. Instead of manually formatting an error message, you pass the caught exception directly and Chromologger extracts the exception class name, the source file where it was raised, the line number, and the full error message — all automatically, using Python’s built-in traceback module.
How it works
When you calllogger.log_e(e), Chromologger calls traceback.extract_tb(e.__traceback__) internally and picks the last frame of the stack — the location where the exception actually occurred. It then writes a single structured line at the [ERROR] level:
| Field | Description |
|---|---|
Exception | The exception class name (e.g. FileNotFoundError, ZeroDivisionError) |
File | Absolute path to the Python file where the exception was raised |
ErrorLine | The line number within that file |
Message | The exception’s string representation |
Basic exception logging
File not found
Catching broad exceptions
You can combinelog_e() with a follow-up log() call to record both the full traceback and a human-readable summary:
[ERROR] entry with the complete traceback detail, and one [INFO] entry acting as a plain-text summary that is easy to grep for.
log_e() extracts traceback information only when the exception has been
raised — that is, when it carries a __traceback__ attribute. If you
construct an exception object manually without raising it (e.g.
e = ValueError("oops")) and pass it to log_e(), the traceback will be
empty and Chromologger will not be able to populate the File or ErrorLine
fields. Always call log_e() from inside an except block.Next steps:
- Multiple Loggers — use separate log files for access, errors, and performance in the same application.
- Logger API Reference — full method signatures and return values.