def test_can_change_log_level(self): fpath = self.start_new_log_file() set_log_severity("", "DEBUG") self.addCleanup(set_log_severity, "", "INFO") log_unity_message("DEBUG", "This is some more INFORMATION") sleep(1) reset_logging() with open(fpath, 'r') as f: self.assertThat(f.read(), Contains("This is some more INFORMATION"))
def set_unity_log_level(self, component, level): """Set the unity log level for 'component' to 'level'. Valid levels are: TRACE, DEBUG, INFO, WARNING and ERROR. Components are dotted unity component names. The empty string specifies the root logging component. """ valid_levels = ('TRACE', 'DEBUG', 'INFO', 'WARN', 'WARNING', 'ERROR') if level not in valid_levels: raise ValueError("Log level '%s' must be one of: %r" % (level, valid_levels)) set_log_severity(component, level)