ansys.fluent.core.logging#
Module controlling PyFluent’s logging functionality.
For a basic user guide, see the logging user guide.
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.logging.configure_env_var()#
Verifies whether
PYFLUENT_LOGGING
environment 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_LOGGING
set to0
orOFF
is 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_LOGGING
toDEBUG
. See also the user guide environment variable subsection.
- ansys.fluent.core.logging.enable(level='DEBUG', custom_config=None)#
Enables PyFluent logging to file.
- Parameters:
- level
str
orint
,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.yaml
file (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.logging.enable()
Customizing logging configuration (see also
get_default_config()
):>>> import ansys.fluent.core as pyfluent >>> config_dict = pyfluent.logging.get_default_config() >>> config_dict['handlers']['pyfluent_file']['filename'] = 'test.log' >>> pyfluent.logging.enable(custom_config=config_dict)
- ansys.fluent.core.logging.get_default_config()#
Returns the default configuration dictionary obtained from parsing from the PyFluent
logging_config.yaml
file.Examples
>>> import ansys.fluent.core as pyfluent >>> pyfluent.logging.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.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.logging.get_logger(*args, **kwargs)#
Retrieves logger.
Convenience wrapper for Python’s
logging.getLogger()
function.
- ansys.fluent.core.logging.is_active()#
Returns whether PyFluent logging to file is active.
- ansys.fluent.core.logging.list_loggers()#
List all PyFluent loggers.
- Returns:
list
of
str
Each list element is a PyFluent logger name that can be individually controlled through
ansys.fluent.core.logging.get_logger()
.
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.logging.enable() >>> pyfluent.logging.list_loggers() ['pyfluent.general', 'pyfluent.launcher', 'pyfluent.networking', ...] >>> logger = pyfluent.logging.get_logger('pyfluent.networking') >>> logger <Logger pyfluent.networking (DEBUG)> >>> logger.setLevel('ERROR') >>> logger <Logger pyfluent.networking (ERROR)>
- ansys.fluent.core.logging.root_config()#
Sets up the root PyFluent logger that outputs messages to stdout, but not to files.
- ansys.fluent.core.logging.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.logging.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.logging.set_global_level(10)
or
>>> pyfluent.logging.set_global_level('DEBUG')