get_logger#

caf.toolkit.log_helpers.get_logger(logger_name, code_version, console_handler=True, instantiate_msg=None, log_file_path=None)[source]#

Create a standard logger using the CAF template.

Creates and sets up the logger, prints out the standard instantiation messages, and returns the logger. If more custom handlers are needed, get_custom_logger() to follow the same standard with more flexibility.

Parameters:
  • logger_name (str) – The name of the new logger.

  • code_version (str) – A string describing the current version of the code being logged.

  • instantiate_msg (str | None) – A message to output on instantiation. This will be output at the logging.DEBUG level, and will be wrapped in a line of asterisk before and after.

  • log_file_path (PathLike | None) – The path to a file to output the log. This uses the default parameters from get_file_handler()

  • console_handler (bool) – Whether to attach a default logging.StreamHandler object, generated by get_console_handler().

Returns:

A logger with the given handlers attached.

Return type:

logger

See also

get_custom_logger() get_file_handler() get_console_handler()