Logging System#

This module contains functions related to sp_logging (Scikit-plots Logging).

Note

The Scikit-plots logging system is meant for internal scikit-plots usage. For use in other packages, we recommend implementing your own logger instead.

Tip

The Scikit-plots logging system compatible with python logging API system. This module defines a logging class based on the built-in logging module.

Configuring the logging system#

First, import the logger, Get a root logger by module:

>>> import scikitplot.sp_logging as logging  # module logger
>>> logging.setLevel(logging.INFO)           # default WARNING
>>> logging.info("This is a info message from the sp logger.")
2025-01-17 22:20:54 INFO scikitplot 140380527740736 sp_logging.py 820 This is a info message from the sp logger. 

Get a root logger by func:

>>> from scikitplot import sp_logging, get_logger; logging=get_logger()  # pure python logger, not have direct log level
>>> logging.setLevel(sp_logging.INFO)                                    # default WARNING
>>> logging.info("This is a info message from the sp logger.")
2025-01-17 22:20:54 INFO scikitplot 140380527740736 1353514787.py 3 This is a info message from the sp logger. 

Get a root logger by class:

>>> from scikitplot import SpLogger; logging=SpLogger()  # class logger
>>> logging.setLevel(logging.INFO)                       # default WARNING
>>> logging.info("This is a info message from the sp logger.")
2025-01-17 22:20:54 INFO scikitplot 140380527740736 sp_logging.py 1146 This is a info message from the sp logger. 

Get a root logger by class instance:

>>> from scikitplot import sp_logger as logging  # class instance logger
>>> logging.setLevel(logging.INFO)               # default WARNING
>>> logging.info("This is a info message from the sp logger.")
2025-01-17 22:20:54 INFO scikitplot 140380527740736 sp_logging.py 1146 This is a info message from the sp logger. 

Note

This module builds on Python’s standard logging library. For more information on Python’s logging API, refer to the official documentation: https://docs.python.org/3/library/logging.html

>>> import logging
>>> logger = logging.getLogger(__name__)
>>> logger.setLevel(logging.DEBUG)

Logging Levels:

  • NOTSET (0) : NOTSET

  • DEBUG (10) : Detailed information useful during development, typically of interest only when diagnosing problems.

  • INFO (20) : Confirmation that things are working as expected.

  • WARNING (30): An indication that something unexpected happened, or indicative of some problem in the near future.

  • ERROR (40) : Due to a more serious problem, the software has not been able to perform some function.

  • CRITICAL = FATAL (50): A very serious error, indicating that the program itself may be unable to continue running.