duo_ai.utils.logging ==================== .. py:module:: duo_ai.utils.logging Classes ------- .. autoapisummary:: duo_ai.utils.logging.ElapsedFormatter Functions --------- .. autoapisummary:: duo_ai.utils.logging.configure_logging Module Contents --------------- .. py:function:: configure_logging(log_file) Configure logging to output to both a file and the console with elapsed time formatting. Sets up logging handlers and a custom exception hook for uncaught exceptions. :param log_file: Path to the log file where logs will be written. :type log_file: str :rtype: None .. rubric:: Examples >>> configure_logging('experiment.log') .. py:class:: ElapsedFormatter Formatter for logging that prepends elapsed time since initialization. :param None: .. attribute:: start_time The time when the formatter was initialized. :type: datetime.datetime .. rubric:: Examples >>> formatter = ElapsedFormatter() >>> formatter.format_time(datetime.now() - formatter.start_time) '0:00:01' .. py:attribute:: start_time .. py:method:: format_time(t) Format a timedelta as a string, omitting microseconds. :param t: Time difference to format. :type t: datetime.timedelta :returns: Formatted time string. :rtype: str .. py:method:: format(record) Format a log record with elapsed time and log level. :param record: The log record to format. :type record: logging.LogRecord :returns: Formatted log string. :rtype: str