Logger#

class ansys.additive.core.logger.Logger(level=logging.DEBUG, to_file=False, to_stdout=True, filename=FILE_NAME)#

Provides the logger used for each PyAdditive session.

This class allows you to add handlers to the logger to output messages to a file or to the standard output (stdout).

Parameters:
leveldefaultDEBUG

Logging level to filter the message severity allowed in the logger.

to_filebool, default: False

Whether to write log messages to a file.

to_stdoutbool, default: True

Whether to write log messages to the standard output.

filenamestr, default: obj:FILE_NAME

Name of the file to write log log messages to.

Overview#

log_to_file

Add a file handler to the logger.

log_to_stdout

Add the standard output handler to the logger.

add_handling_uncaught_expections

Redirect the output of an exception to a logger.

setLevel

Set the logging level for the logger.

Import detail#

from ansys.additive.core.logger import Logger

Attribute detail#

Logger.file_handler = None#
Logger.stdout_handler = None#
Logger.logger#
Logger.debug#
Logger.info#
Logger.warning#
Logger.error#
Logger.critical#
Logger.log#

Method detail#

Logger.log_to_file(filename=FILE_NAME, level=LOG_LEVEL)#

Add a file handler to the logger.

Parameters:
filenamestr, default: obj:FILE_NAME

Name of the file to write log messages to.

leveldefaultDEBUG

Logging level to filter the message severity allowed in the logger.

Logger.log_to_stdout(level=LOG_LEVEL)#

Add the standard output handler to the logger.

Parameters:
leveldefaultDEBUG

Logging level to filter the message severity allowed in the logger.

Logger.add_handling_uncaught_expections(logger)#

Redirect the output of an exception to a logger.

Parameters:
loggerstr

Name of the logger.

Logger.setLevel(level: str | int) None#

Set the logging level for the logger.

Parameters:
levelstr or int

Logging level to filter the message severity allowed in the logger. If int, it must be one of the levels defined in the logging module. Valid string values are "DEBUG", "INFO", "WARNING", "ERROR", and "CRITICAL".