get_logger#

scikitplot.sp_logging.get_logger()[source]#

Return SP (scikitplot) logger instance.

Returns:
logging.Logger

An instance of the Python logging library Logger.

Return type:

Logger

See also

SpLogger

A singleton logger class that provides a shared logging.Logger instance with customizable name, formatter, handler, logging level, and thread-safety.

sp_logger

An instance of SpLogger class, providing logging logger functionality.

logging.getLogger

Standard library function to retrieve logging.Logger instance. For more: https://docs.python.org/3/library/logging.html

Notes

See Python documentation (https://docs.python.org/3/library/logging.html) for detailed API. Below is only a summary.

The logger has 5 levels of logging from the most serious to the least:

  1. CRITICAL or FATAL

  2. ERROR

  3. WARNING

  4. INFO

  5. DEBUG

  6. NOTSET

The logger has the following methods, based on these logging levels:

  1. critical(msg, *args, **kwargs) or fatal(msg, *args, **kwargs)

  2. error(msg, *args, **kwargs)

  3. warning(msg, *args, **kwargs) or warn(msg, *args, **kwargs)

  4. info(msg, *args, **kwargs)

  5. debug(msg, *args, **kwargs)

The msg can contain string formatting. An example of logging at the ERROR level using string formatting is:

>>> sp.get_logger().error("The value %d is invalid.", 3)

You can also specify the logging verbosity. In this case, the WARN level log will not be emitted:

>>> sp.get_logger().setLevel(sp.sp_logging.WARNING)
>>> sp.get_logger().debug(
...     "This is a debug."
... )  # This will not be shown, as level is WARNING.
>>> sp.get_logger().info(
...     "This is a info."
... )  # This will not be shown, as level is WARNING.
>>> sp.get_logger().warning("This is a warning.")

Examples

Use a root logger by module:

>>> from scikitplot import logger
>>> logger.setLevel(logger.INFO)  # default WARNING
>>> logger.info("This is a info message from the sp logger.")
2025-05-29 20:29:12.534389: I scikitplot 139630681955200 948823027.py:3:<module>] This is a info message from the sp logger.

Get a root logger by func:

>>> from scikitplot import logger
>>> logger.setLevel(logger.INFO)  # default WARNING
>>> logger.info("This is a info message from the sp logger.")
2025-05-29 20:29:12.540570: I scikitplot 139630681955200 948823027.py:3:<module>] This is a info message from the sp logger.