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: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
parent
6473d2082b
commit
bd91f06d17
2 changed files with 7 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue