logger#
Module controlling PyFluent’s logging functionality.
Functions:
Verifies whether |
|
|
Enables PyFluent logging to file. |
Returns the default configuration dictionary obtained from parsing from the PyFluent |
|
|
Retrieves logger. |
Returns whether PyFluent logging to file is active. |
|
List all PyFluent loggers. |
|
Sets up the root PyFluent logger that outputs messages to stdout, but not to files. |
|
|
Sets the level of PyFluent logging being output to console. |
|
Changes the levels of all PyFluent loggers that write to log file. |
- ansys.fluent.core.logger.configure_env_var()#
Verifies whether
PYFLUENT_LOGGINGenvironment variable was defined in the system. Executed once automatically on PyFluent initialization.Notes
The usual way to enable PyFluent logging to file is through
enable().PYFLUENT_LOGGINGset to0orOFFis the same as if no environment variable was set. If logging debug output to file by default is desired, without having to useenable()every time, set environment variablePYFLUENT_LOGGINGtoDEBUG.
- ansys.fluent.core.logger.enable(level='DEBUG', custom_config=None)#
Enables PyFluent logging to file.
- Parameters:
- level
strorint,optional Specified logging level to set PyFluent loggers to. If omitted, level is set to DEBUG.
- custom_config
dict,optional Used to provide a customized logging configuration file that will be used instead of the
logging_config.yamlfile (see alsoget_default_config()).
- level
Notes
See logging levels in https://docs.python.org/3/library/logging.html#logging-levels
Examples
Using the default logging setup:
>>> import ansys.fluent.core as pyfluent >>> pyfluent.logger.enable()
Customizing logging configuration (see also
get_default_config()):>>> import ansys.fluent.core as pyfluent >>> config_dict = pyfluent.logger.get_default_config() >>> config_dict['handlers']['pyfluent_file']['filename'] = 'test.log' >>> pyfluent.logger.enable(custom_config=config_dict)
- ansys.fluent.core.logger.get_default_config()#
Returns the default configuration dictionary obtained from parsing from the PyFluent
logging_config.yamlfile.Examples
>>> import ansys.fluent.core as pyfluent >>> pyfluent.logger.get_default_config() {'disable_existing_loggers': False, 'formatters': {'logfile_fmt': {'format': '%(asctime)s %(name)-21s ' '%(levelname)-8s %(message)s'}}, 'handlers': {'pyfluent_file': {'backupCount': 9, 'class': 'logging.handlers.RotatingFileHandler', 'filename': 'pyfluent.log', 'formatter': 'logfile_fmt', 'level': 'NOTSET', 'maxBytes': 10485760}}, 'loggers': {'pyfluent.datamodel': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.field_data': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.general': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.launcher': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.networking': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.post_objects': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.settings_api': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.tui': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}}, 'version': 1}
- ansys.fluent.core.logger.get_logger(*args, **kwargs)#
Retrieves logger.
Convenience wrapper for Python’s
logging.getLogger()function.
- ansys.fluent.core.logger.is_active()#
Returns whether PyFluent logging to file is active.
- ansys.fluent.core.logger.list_loggers()#
List all PyFluent loggers.
- Returns:
Notes
PyFluent loggers use the standard Python logging library, for more details see https://docs.python.org/3/library/logging.html#logger-objects
Examples
>>> import ansys.fluent.core as pyfluent >>> pyfluent.logger.enable() >>> pyfluent.logger.list_loggers() ['pyfluent.general', 'pyfluent.launcher', 'pyfluent.networking', ...] >>> logger = pyfluent.logger.get_logger('pyfluent.networking') >>> logger <Logger pyfluent.networking (DEBUG)> >>> logger.setLevel('ERROR') >>> logger <Logger pyfluent.networking (ERROR)>
- ansys.fluent.core.logger.root_config()#
Sets up the root PyFluent logger that outputs messages to stdout, but not to files.
- ansys.fluent.core.logger.set_console_logging_level(level)#
Sets the level of PyFluent logging being output to console.
Notes
See logging levels in https://docs.python.org/3/library/logging.html#logging-levels
- ansys.fluent.core.logger.set_global_level(level)#
Changes the levels of all PyFluent loggers that write to log file.
Notes
See logging levels in https://docs.python.org/3/library/logging.html#logging-levels
Examples
>>> import ansys.fluent.core as pyfluent >>> pyfluent.logger.set_global_level(10)
or
>>> pyfluent.logger.set_global_level('DEBUG')