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: (1) redirect logging to a log file, (2) redirect logging to the console or (3) disable logging (see examples). Use level parameter to fine tune logging level. All pytwin objects (from the same python process) share the same logging options.
- Parameters:
- new_option
PyTwinLogOption
Option you want to use for pytwin logging.
- new_level: PyTwinLogLevel
Level you want to use for pytwin logging.
- new_option
- Raises:
PyTwinSettingsError
If new_option is not a valid PyTwinLogOption attribute. if new_level is not a valid PyTwinLogLevel attribute.
Examples
>>> # Redirect logging to a file in the working directory >>> from pytwin import modify_pytwin_logging, get_pytwin_log_file >>> from pytwin import PYTWIN_LOGGING_OPT_FILE, PYTWIN_LOG_DEBUG >>> 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)