PymapdlCustomAdapter#

class ansys.dyna.core.solver.dynalogging.PymapdlCustomAdapter(logger, extra=None)#

Bases: logging.LoggerAdapter

Adapter for keeping the reference to an MAPDL instance name dynamic.

Using the standard approach, extra parameters must be supplied to the logger to indicate the MAPDL instance for which messages must be logged.

With this class, you only have to specify the MAPDL instance that you are referring to once.

Overview#

process

Process the logging message and keyword arguments passed in to

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.dyna.core.solver.dynalogging import PymapdlCustomAdapter

Attribute detail#

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

Method detail#

PymapdlCustomAdapter.process(msg, kwargs)#

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.

Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.

PymapdlCustomAdapter.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 LOG_LEVEL, which causes all messages to be recorded. For example, you can set the level of logging to DEBUG.

PymapdlCustomAdapter.log_to_stdout(level=LOG_LEVEL)#

Add a standard output handler to the logger.

Parameters:
levelstr, optional

Level of logging record. The default is LOG_LEVEL, which causes all messages to be recorded. For example, you can set the level of logging to "DEBUG".

PymapdlCustomAdapter.setLevel(level='DEBUG')#

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

Parameters:
levelstr, optional

Level of logging record. The default is "DEBUG.