def init(format_prefix="", output_mode=OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path=DEFAULT_LOGFILE_PATH): if output_mode == "/dev/null": assert output_mode != OutputMode.LOGFILE, "Must enable a logging mode." output_mode = OutputMode.CONSOLE # Start with the default logging.config.dictConfig( get_default_config( format_prefix, output_mode, logfile_path ) ) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str(lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format
def init(format_prefix="", output_mode=OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path=DEFAULT_LOGFILE_PATH): if output_mode == "/dev/null": assert output_mode != OutputMode.LOGFILE, "Must enable a logging mode." output_mode = OutputMode.CONSOLE # Start with the default logging.config.dictConfig( get_default_config(format_prefix, output_mode, logfile_path)) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str( lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format
def init(format_prefix="", output_mode=OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path=DEFAULT_LOGFILE_PATH): if logfile_path == "/dev/null": assert output_mode != OutputMode.LOGFILE, "Must enable a logging mode." output_mode = OutputMode.CONSOLE # Preserve pre-existing handlers original_root_handlers = list(logging.getLogger().handlers) # Start with the default default_config = get_default_config(format_prefix, output_mode, logfile_path) logging.config.dictConfig(default_config) # Preserve pre-existing handlers for handler in original_root_handlers: logging.getLogger().addHandler(handler) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Don't warn about duplicate python bindings for opengm # (We import opengm twice, as 'opengm' 'opengm_with_cplex'.) warnings.filterwarnings("ignore", message='.*to-Python converter for .*opengm.*', category=RuntimeWarning) # Hide all other python converter warnings unless we're in debug mode. if not ilastik_config.getboolean("ilastik", "debug"): warnings.filterwarnings( "ignore", message= '.*to-Python converter for .*second conversion method ignored.*', category=RuntimeWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str( lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format
def init(format_prefix="", output_mode=OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path=DEFAULT_LOGFILE_PATH): if logfile_path == "/dev/null": assert output_mode != OutputMode.LOGFILE, "Must enable a logging mode." output_mode = OutputMode.CONSOLE # Preserve pre-existing handlers original_root_handlers = list(logging.getLogger().handlers) # Start with the default default_config = get_default_config( format_prefix, output_mode, logfile_path ) logging.config.dictConfig( default_config ) # Preserve pre-existing handlers for handler in original_root_handlers: logging.getLogger().addHandler(handler) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Don't warn about duplicate python bindings for opengm # (We import opengm twice, as 'opengm' 'opengm_with_cplex'.) warnings.filterwarnings("ignore", message='.*to-Python converter for .*opengm.*', category=RuntimeWarning) # Hide all other python converter warnings unless we're in debug mode. if not ilastik_config.getboolean("ilastik", "debug"): warnings.filterwarnings("ignore", message='.*to-Python converter for .*second conversion method ignored.*', category=RuntimeWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str(lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format
def init(format_prefix=""): # Start with the default logging.config.dictConfig( get_default_config( format_prefix ) ) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str(lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format
def init(): # Start with the default logging.config.dictConfig(default_log_config) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str( lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format