Skip to main content
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 call logger.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:
The fields in the output are:

Basic exception logging

Resulting log line:

File not found

Catching broad exceptions

You can combine log_e() with a follow-up log() call to record both the full traceback and a human-readable summary:
This produces two lines in the log file: one [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: