Logger#

class ansys.tools.common.logger.Logger(level: int = logging.ERROR, logger_name: str = 'Logger', column_width: int = 15)#

Bases: object

Provides the singleton logger.

Parameters#

levelint, default: logging.ERROR

Output level of the logger.

logger_namestr, default: "Logger"

Name of the logger.

column_widthint, default: 15

Maximum width of the module and function names in the log output.

Overview#

get_logger

Get the logger.

set_level

Set the logger output level.

enable_output

Enable logger output to a given stream.

add_file_handler

Save logs to a file in addition to printing them to the standard output.

debug

Log a message with level DEBUG.

info

Log a message with level INFO.

warning

Log a message with level WARNING.

warn

Log a message with level WARNING.

error

Log a message with level ERROR.

critical

Log a message with level CRITICAL.

fatal

Log a message with level FATAL.

log

Log a message with a specified level.

Import detail#

from ansys.tools.common.logger import Logger

Method detail#

Logger.get_logger()#

Get the logger.

Returns#

Logger

Logger.

Logger.set_level(level: int)#

Set the logger output level.

Parameters#

levelint

Output level of the logger.

Logger.enable_output(stream=None)#

Enable logger output to a given stream.

If a stream is not specified, sys.stderr is used.

Parameters#

stream: TextIO, default: None

Stream to output the log output to.

Logger.add_file_handler(logs_dir: str | pathlib.Path = '.log')#

Save logs to a file in addition to printing them to the standard output.

Parameters#

logs_dirstr or Path, default: ".log"

Directory to save the log file to. If it does not exist, it is created.

Logger.debug(*args, **kwargs)#

Log a message with level DEBUG.

Logger.info(*args, **kwargs)#

Log a message with level INFO.

Logger.warning(*args, **kwargs)#

Log a message with level WARNING.

Logger.warn(*args, **kwargs)#

Log a message with level WARNING.

Logger.error(*args, **kwargs)#

Log a message with level ERROR.

Logger.critical(*args, **kwargs)#

Log a message with level CRITICAL.

Logger.fatal(*args, **kwargs)#

Log a message with level FATAL.

Logger.log(level, msg, *args, **kwargs)#

Log a message with a specified level.