modify_pytwin_logging#
- pytwin.modify_pytwin_logging(new_option=PyTwinLogOption.PYTWIN_LOGGING_OPT_FILE, new_level=PyTwinLogLevel.PYTWIN_LOG_INFO)#
Modify global PyTwin logging.
You can choose to take these actions:
Redirect logging to a log file.
Redirect logging to the console.
Disable logging.
All PyTwin objects from the same Python process share the same logging options. To fine tune the logging level, use the
new_levelparameter. For more information, see the examples.- Parameters:
- new_option
PyTwinLogOption Option to use for PyTwin logging.
- new_level: PyTwinLogLevel
Level to use for PyTwin logging.
- new_option
- Raises:
PyTwinSettingsErrorIf
new_optionis not a validPyTwinLogOptionattribute. Ifnew_levelis not a validPyTwinLogLevelattribute.
Examples
>>> from pytwin import modify_pytwin_logging, get_pytwin_log_file >>> from pytwin import PYTWIN_LOGGING_OPT_FILE, PYTWIN_LOG_DEBUG >>> # >>> # Redirect logging to a file in the working directory and set logging level to DEBUG level >>> modify_pytwin_logging(new_option=PYTWIN_LOGGING_OPT_FILE, new_level=PYTWIN_LOG_DEBUG) >>> print(get_pytwin_log_file()) >>> # >>> # Redirect logging to the console >>> from pytwin import modify_pytwin_logging, PYTWIN_LOGGING_OPT_CONSOLE >>> modify_pytwin_logging(PYTWIN_LOGGING_OPT_CONSOLE) >>> # >>> # Disable logging >>> from pytwin import modify_pytwin_logging, PYTWIN_LOGGING_OPT_NOLOGGING >>> modify_pytwin_logging(PYTWIN_LOGGING_OPT_NOLOGGING)