LoggingΒΆ
By default, ocelote will log progress messages to the console. This page provides instructions for customizing the logging streams. Ocelote does not configure the logger when running within a Python session, which means you can modify the log streams and formats using the standard logging library. Ocelote uses a uniquely named logger for each command. These follow the standard Python dot-indexing namespace notation. For example: ocelote.initialize.version
, ocelote.download
, ocelote.run
, ocelote.upload.s3
, etc.
For example, you can use the following snippet to log detailed preprocessing messages to the console in the CLI style:
import logging
logger = logging.getLogger('ocelote.preprocess')
logger.setLevel(logging.DEBUG)
to_console = logging.StreamHandler()
to_console.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(message)s")
to_console.setFormatter(formatter)
logger.addHandler(to_console)
Analogously, the following snippet will log detailed progress messages to file in the CLI style:
import logging
logger = logging.getLogger('ocelote.preprocess')
logger.setLevel(logging.DEBUG)
to_file = logging.FileHandler('my-file.txt')
to_file.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(message)s")
to_file.setFormatter(formatter)
logger.addHandler(to_file)