Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1.09 KB

logging.rst

File metadata and controls

37 lines (24 loc) · 1.09 KB

Logging

In alchemlyb, we use :mod:`loguru` for logging. By default, the :mod:`loguru` will print the logging information into the sys.stderr.

Print to the stderr

If you want to customise the printing to the stderr, you could remove the existing sink first

from loguru import logger
logger.remove()

Then add other custom sink

logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")

The loguru logger is compatible with the :mod:`logging` module of the Python standard library and can easily be configured to log to a logging handler.

Save to a file

Alternatively, one could save to a file simply with

from loguru import logger
logger.add("file_{time}.log")

See configure to log to a file for more explanation.