Michał Gozdera
05/19/2025, 10:48 AMspaceflights-pandas
we have info_file_handler
defined which logs into info.log
file, but when a DatasetError is raised (for example the dataset csv file is missing), it is not logged in info.log (traceback and error is visible only in console).
How to make it be logged in the log file a well? I can always define a hook like this:
class ErrorCatchLoggingHook:
@hook_impl
def on_pipeline_error(self, error: Exception):
logger.exception(f"Pipeline failed due to an error: {str(error)}")
but then the error log in the console is duplicated.Rashida Kanchwala
05/19/2025, 11:19 AMRichHandler
in the root logger.
I was able to fix it by removing rich
from root.handlers
in logging.yml
and keeping only info_file_handler
.Nok Lam Chan
05/19/2025, 11:34 AMrich
or console
handler.
Traceback is normally not part of the "logging", the things that you can see on a console is the systemhook (and modified by rich if you are using it).Nok Lam Chan
05/19/2025, 11:38 AMroot
, the default will pass it (I forgot what's the configuration but you can google this)
2. Register the info_file_handler
to the logger
3. use something like the hook you created with the custom loggerMichał Gozdera
05/22/2025, 3:37 PM