nspyre.misc.logging

Module Contents

Functions

nspyre_init_logger(log_level[, log_path, ...])

Initialize system-wide logging to stdout/err and, optionally, a file.

Attributes

LOG_FILE_MAX_SIZE

Max size of a log file (in bytes) before creating a new one.

nspyre.misc.logging.LOG_FILE_MAX_SIZE = 10000000.0

Max size of a log file (in bytes) before creating a new one.

nspyre.misc.logging.nspyre_init_logger(log_level, log_path=None, log_path_level=None, prefix='', file_size=None, remove_handlers=True)

Initialize system-wide logging to stdout/err and, optionally, a file.

Parameters:
  • log_level (int) – Log messages of lower severity than this will not be sent to stdout/err (e.g. logging.INFO).

  • log_path (Optional[pathlib.Path]) – If a file, log to that file. If a directory, generate a log file name containing the prefix and date/time, and create a new log file in that directory. If None, only log to stdout/err.

  • log_path_level (Optional[int]) – Logging level for the log file. Leave as None for same as log_level.

  • prefix (str) – If a directory was specified for log_path, prepend this string to the log file name.

  • file_size (Optional[int]) – Maximum log file size (bytes). If this size is exceeded, the log file is rotated according to RotatingFileHandler (https://docs.python.org/3/library/logging.handlers.html).

  • remove_handlers (bool) – If true, remove any existing log handlers.