Skip to content
Snippets Groups Projects
Unverified Commit 6f821caa authored by Rodrigo Tobar's avatar Rodrigo Tobar
Browse files

Use different log levels depending on result code


Different result codes mean different things, and thus logging all of
them at INFO level can be confusing when one is scrolling through many
lines of logs looking for errors.

This commit changes the level at which command results are logged
depending on their result codes.

This work was performed as part of YAN-688.

Signed-off-by: default avatarRodrigo Tobar <rtobar@icrar.org>
parent 48e2ea99
No related branches found
No related tags found
No related merge requests found
......@@ -174,6 +174,14 @@ class ResponseCommand(BaseCommand):
tuple.
"""
RESULT_LOG_LEVEL = {
ResultCode.OK: logging.INFO,
ResultCode.STARTED: logging.INFO,
ResultCode.QUEUED: logging.INFO,
ResultCode.FAILED: logging.ERROR,
ResultCode.UNKNOWN: logging.WARNING
}
def __call__(self, argin=None):
"""
What to do when the command is called. This base class simply
......@@ -208,7 +216,8 @@ class ResponseCommand(BaseCommand):
else:
(return_code, message) = self.do(argin=argin)
self.logger.info(
self.logger.log(
self.RESULT_LOG_LEVEL.get(return_code, logging.ERROR),
f"Exiting command {self.name} with return_code {return_code!s}, "
f"message: '{message}'"
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment