add_instance_logger#

Logger.add_instance_logger(name, mechanical_instance, level=None)#

Add a logger for a Mechanical instance.

The logger for a Mechanical instance has an adapter that adds contextual information, such as the name of the Mechanical instance. This logger is returned, and you can use it to log events as a normal logger. It is also stored in the _instances field.

Parameters:
namestr

Name for the new logger.

mechanical_instanceansys.mechanical.core.mechanical.Mechanical

Mechanical instance object. This object should contain the name attribute.

levelstr, optional

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

Returns:
ansys.mechanical.core.logging.PyMechanicalCustomAdapter

Logger adapter customized to add Mechanical information to the logs. You can use this class to log events in the same way you would with the logger class.

Raises:
Exception

You can only input strings as name to this method.