diff --git a/tuned/consts.py b/tuned/consts.py index d81b69b..00a841c 100644 --- a/tuned/consts.py +++ b/tuned/consts.py @@ -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" diff --git a/tuned/logs.py b/tuned/logs.py index e3da574..d881b54 100644 --- a/tuned/logs.py +++ b/tuned/logs.py @@ -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)