remove common log level
This commit is contained in:
parent
6ae3355f3c
commit
96b22672d6
4 changed files with 17 additions and 16 deletions
|
@ -73,18 +73,19 @@ template:
|
||||||
|
|
||||||
# Logging setup
|
# Logging setup
|
||||||
logging:
|
logging:
|
||||||
# Logging level
|
|
||||||
# Allowed levels are 'INFO', 'WARNING', 'ERROR', 'DEBUG' where DEBUG is most verbose
|
|
||||||
level: INFO
|
|
||||||
# Configure logging to a file
|
# Configure logging to a file
|
||||||
file_logging:
|
file_logging:
|
||||||
# Whether logging to a file is enabled
|
# Whether logging to a file is enabled
|
||||||
enabled: false
|
enabled: false
|
||||||
# Logging level specific to file logging (optional)
|
# Logging level specific to file logging (optional)
|
||||||
level: WARN
|
level: DEBUG
|
||||||
# The path to the file to log to. May be relative or absolute
|
# The path to the file to log to. May be relative or absolute
|
||||||
filepath: matrix-alertbot.log
|
filepath: matrix-alertbot.log
|
||||||
# Configure logging to the console output
|
# Configure logging to the console output
|
||||||
console_logging:
|
console_logging:
|
||||||
# Whether logging to the console is enabled
|
# Whether logging to the console is enabled
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# Logging level specific to console (optional)
|
||||||
|
# Allowed levels are 'INFO', 'WARNING', 'ERROR', 'DEBUG' where DEBUG is most verbose
|
||||||
|
level: INFO
|
||||||
|
|
|
@ -67,8 +67,9 @@ class Config:
|
||||||
"%(asctime)s | %(name)s [%(levelname)s] %(message)s"
|
"%(asctime)s | %(name)s [%(levelname)s] %(message)s"
|
||||||
)
|
)
|
||||||
|
|
||||||
log_level = self._get_cfg(["logging", "level"], default="INFO")
|
# this must be DEBUG to allow debug messages
|
||||||
logger.setLevel(log_level)
|
# actual log levels are defined in the handlers below
|
||||||
|
logger.setLevel("DEBUG")
|
||||||
|
|
||||||
file_logging_enabled = self._get_cfg(
|
file_logging_enabled = self._get_cfg(
|
||||||
["logging", "file_logging", "enabled"], default=False
|
["logging", "file_logging", "enabled"], default=False
|
||||||
|
@ -77,7 +78,7 @@ class Config:
|
||||||
["logging", "file_logging", "filepath"], default="matrix-alertbot.log"
|
["logging", "file_logging", "filepath"], default="matrix-alertbot.log"
|
||||||
)
|
)
|
||||||
file_logging_log_level = self._get_cfg(
|
file_logging_log_level = self._get_cfg(
|
||||||
["logging", "file_logging", "level"], required=False
|
["logging", "file_logging", "level"], default="INFO"
|
||||||
)
|
)
|
||||||
if file_logging_enabled:
|
if file_logging_enabled:
|
||||||
file_handler = logging.FileHandler(file_logging_filepath)
|
file_handler = logging.FileHandler(file_logging_filepath)
|
||||||
|
@ -90,7 +91,7 @@ class Config:
|
||||||
["logging", "console_logging", "enabled"], default=True
|
["logging", "console_logging", "enabled"], default=True
|
||||||
)
|
)
|
||||||
console_logging_log_level = self._get_cfg(
|
console_logging_log_level = self._get_cfg(
|
||||||
["logging", "console_logging", "level"], required=False
|
["logging", "console_logging", "level"], default="INFO"
|
||||||
)
|
)
|
||||||
if console_logging_enabled:
|
if console_logging_enabled:
|
||||||
console_handler = logging.StreamHandler(sys.stdout)
|
console_handler = logging.StreamHandler(sys.stdout)
|
||||||
|
|
|
@ -90,15 +90,14 @@ template:
|
||||||
|
|
||||||
# Logging setup
|
# Logging setup
|
||||||
logging:
|
logging:
|
||||||
# Logging level
|
|
||||||
# Allowed levels are 'INFO', 'WARNING', 'ERROR', 'DEBUG' where DEBUG is most verbose
|
|
||||||
level: DEBUG
|
|
||||||
# Configure logging to a file
|
# Configure logging to a file
|
||||||
file_logging:
|
file_logging:
|
||||||
# Whether logging to a file is enabled
|
# Whether logging to a file is enabled
|
||||||
enabled: true
|
enabled: true
|
||||||
# The path to the file to log to. May be relative or absolute
|
# The path to the file to log to. May be relative or absolute
|
||||||
filepath: fake.log
|
filepath: fake.log
|
||||||
|
# Logging level specific to file (optional)
|
||||||
|
# Allowed levels are 'INFO', 'WARNING', 'ERROR', 'DEBUG' where DEBUG is most verbose
|
||||||
level: INFO
|
level: INFO
|
||||||
# Configure logging to the console output
|
# Configure logging to the console output
|
||||||
console_logging:
|
console_logging:
|
||||||
|
|
|
@ -60,9 +60,9 @@ class ConfigTestCase(unittest.TestCase):
|
||||||
fake_path_exists.assert_called_once_with("data/store")
|
fake_path_exists.assert_called_once_with("data/store")
|
||||||
fake_mkdir.assert_called_once_with("data/store")
|
fake_mkdir.assert_called_once_with("data/store")
|
||||||
|
|
||||||
fake_logger.setLevel.assert_called_once_with("INFO")
|
fake_logger.setLevel.assert_called_once_with("DEBUG")
|
||||||
fake_logger.addHandler.assert_called_once()
|
fake_logger.addHandler.assert_called_once()
|
||||||
fake_logging.StreamHandler.return_value.setLevel("INFO")
|
fake_logging.StreamHandler.return_value.setLevel.assert_called_once_with("INFO")
|
||||||
fake_logging.StreamHandler.assert_called_once_with(sys.stdout)
|
fake_logging.StreamHandler.assert_called_once_with(sys.stdout)
|
||||||
|
|
||||||
self.assertEqual({"@fakes_user:matrix.example.com"}, config.user_ids)
|
self.assertEqual({"@fakes_user:matrix.example.com"}, config.user_ids)
|
||||||
|
@ -118,7 +118,7 @@ class ConfigTestCase(unittest.TestCase):
|
||||||
|
|
||||||
fake_logger.setLevel.assert_called_once_with("DEBUG")
|
fake_logger.setLevel.assert_called_once_with("DEBUG")
|
||||||
fake_logger.addHandler.assert_called_once()
|
fake_logger.addHandler.assert_called_once()
|
||||||
fake_logging.FileHandler.return_value.setLevel("DEBUG")
|
fake_logging.FileHandler.return_value.setLevel.assert_called_once_with("INFO")
|
||||||
fake_logging.FileHandler.assert_called_once_with("fake.log")
|
fake_logging.FileHandler.assert_called_once_with("fake.log")
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -410,8 +410,8 @@ class ConfigTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(2, fake_logger.addHandler.call_count)
|
self.assertEqual(2, fake_logger.addHandler.call_count)
|
||||||
fake_logger.setLevel.assert_called_once_with("DEBUG")
|
fake_logger.setLevel.assert_called_once_with("DEBUG")
|
||||||
fake_logging.FileHandler.return_value.setLevel.assert_called_with("WARN")
|
fake_logging.FileHandler.return_value.setLevel.assert_called_once_with("WARN")
|
||||||
fake_logging.StreamHandler.return_value.setLevel.assert_called_with("ERROR")
|
fake_logging.StreamHandler.return_value.setLevel.assert_called_once_with("ERROR")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue