CorrHOD.logging#

CorrHOD.logging.log_newline(self, how_many_lines=1)[source][source]#

Add a blank to the logger. Accessed as a method of the logger object with types.MethodType(log_newline, logger)

CorrHOD.logging.create_logger(name: str, level=logging.INFO, stream=sys.stdout, filename: Optional[str] = None, filemode: str = 'w', propagate=False)[source][source]#

Will get or create the loger with the given name, and add a method to the logger object to output a blank line. A handler is created, with the given level and stream (or file output).

Parameters:
  • name (str) – Name of the logger

  • level (optional) – Level of the logger and handler. Can be a string (‘info’, ‘debug’, ‘warning’) or a logging level (logging.INFO, logging.DEBUG, logging.WARNING). Defaults to logging.INFO

  • stream (optional) – Stream to which the logger will output. Defaults to sys.stdout

  • filename (str, optional) – Path to the file to which the logger will output. Defaults to None

  • filemode (str, optional) – Mode to open the file. Defaults to ‘w’

  • propagate (bool, optional) – Whether to propagate the logs to the root logger. Defaults to False Warning : If sets to False, the logs will not be propagated to the root logger, and will not be output by the root logger. If the root logger outputs to a file, the logs will not be saved in the file, unless the logger has the same output file. However, if propagate is True, the logs will be output twice if the root has a different handler (once by the logger, once by the root logger)

Returns:

logger – Logger object

Return type:

logging.Logger