Commit bd91f06d authored by Ondřej Lysoněk's avatar Ondřej Lysoněk

log: Introduce log level CONSOLE

This level has the highest severity. It is meant for important messages
about situations which may require user intervention. These messages
will be shown to the user on the console when running tuned-adm (this is
implemented in a followup commit).
Signed-off-by: default avatarOndřej Lysoněk <olysonek@redhat.com>
parent 6473d208
......@@ -110,3 +110,6 @@ ADMIN_TIMEOUT = 600
# was set automatically or manually
ACTIVE_PROFILE_AUTO = "auto"
ACTIVE_PROFILE_MANUAL = "manual"
LOG_LEVEL_CONSOLE = 60
LOG_LEVEL_CONSOLE_NAME = "CONSOLE"
......@@ -40,6 +40,9 @@ class TunedLogger(logging.getLoggerClass()):
self.setLevel(logging.INFO)
self.switch_to_console()
def console(self, msg, *args, **kwargs):
self.log(consts.LOG_LEVEL_CONSOLE, msg, *args, **kwargs)
def switch_to_console(self):
self._setup_console_handler()
self.remove_all_handlers()
......@@ -78,5 +81,6 @@ class TunedLogger(logging.getLoggerClass()):
filename, maxBytes = consts.LOG_FILE_MAXBYTES, backupCount = consts.LOG_FILE_COUNT)
cls._file_handler.setFormatter(cls._formatter)
logging.addLevelName(consts.LOG_LEVEL_CONSOLE, consts.LOG_LEVEL_CONSOLE_NAME)
logging.setLoggerClass(TunedLogger)
atexit.register(logging.shutdown)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment