Skip to content

GPC Logging

The GPC includes LOGGER, a global logging object that wraps Python3 logging. You can use logger to record information, such as error messages, directly in your order run logs.

Methods

Logger supports several methods, each supporting a different use case.

Use LOGGER.info() to print basic messages to order run logs.

LOGGER.info("Message that you want to add to logs here")

Tip

Use the Search logs field to search for specific messages in an order run log.

Logging levels

Automation supports the following logging levels:

LOGGER.info()
LOGGER.debug()
LOGGER.warning()
LOGGER.error()
LOGGER.critical()

Depending on the severity level set, the order run log message may appear highlighted in a different color, for improved visibility.

Set level

The default level of LOGGER.setLevel() is warning. This method requires import logging in your Python script to change the default level.

import logging

LOGGER.setLevel(logging.DEBUG)

Call logger from a secondary file

If you're running multiple Python files from the same General Purpose Container, you use logger in a secondary file.

Add the following to any accompanying files:

import logging
LOGGER = logging.getLogger(__name__)

LOGGER.info("Your message here")

Python print()

Automation also provides support for the Python print() function.

You can use print("Your message here") in any of your GPC .py files in place of LOGGER.info().

Warning

print() may not show accurate message timings in the order run logs. If log message timestamps are important to your DataOps work, use LOGGER.info().