PyMechanicalCustomAdapter#

class ansys.mechanical.core.logging.PyMechanicalCustomAdapter(logger, extra=None)#

Bases: logging.LoggerAdapter

Keeps the reference to the name of the Mechanical instance dynamic.

The standard approach supplies extra input to the logger. If this approach was used, Mechanical instances would have to be inputted every time a log is created.

Using an adapter means that the reference to the Mechanical instance must only be specified once.

Overview#

process

Process the message.

log_to_file

Add a file handler to the logger.

log_to_stdout

Add a standard output handler to the logger.

setLevel

Change the log level of the object and the attached handlers.

Import detail#

from ansys.mechanical.core.logging import PyMechanicalCustomAdapter

Attribute detail#

PyMechanicalCustomAdapter.level = None#
PyMechanicalCustomAdapter.file_handler = None#
PyMechanicalCustomAdapter.stdout_handler = None#
PyMechanicalCustomAdapter.logger#
PyMechanicalCustomAdapter.std_out_handler#

Method detail#

PyMechanicalCustomAdapter.process(msg, kwargs)#

Process the message.

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

Add a file handler to the logger.

Parameters:
filenamestr, optional

Name of the file where logs are recorded. The default is FILE_NAME.

levelstr, optional

Level of logging. The default is None, in which case the "DEBUG" level is used. Options are "DEBUG", "INFO", "WARNING", and "ERROR".

PyMechanicalCustomAdapter.log_to_stdout(level=LOG_LEVEL)#

Add a standard output handler to the logger.

Parameters:
levelstr, optional

Level of logging. The default is None, in which case the "DEBUG" level is used. Options are "DEBUG", "INFO", "WARNING", and "ERROR".

PyMechanicalCustomAdapter.setLevel(level='DEBUG')#

Change the log level of the object and the attached handlers.

Parameters:
levelstr, optional

Level of logging. The default is "DEBUG". Options are "DEBUG", "INFO", "WARNING", and "ERROR".