From 4882147d6ca38a5a39db251b18672dfd4a055fb1 Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Fri, 25 Jul 2014 21:33:57 -0500 Subject: [PATCH] Minor fix to remove extra colon from logging Some log messages with no file context include a colon delimiter following [], which looks strange and is not desired. Fix includes minor tweak to a few tests' expected output. --- salve/util/log.py | 6 +++--- tests/unit/execute/modify_test.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/salve/util/log.py b/salve/util/log.py index f4e3d9e..9cf161e 100644 --- a/salve/util/log.py +++ b/salve/util/log.py @@ -89,11 +89,11 @@ def log(self, log_type, message, file_context=None, # if hide_context is false, prepend it to the message with # a colon separator. Otherwise, it will be omitted if not hide_context: - ctx_prefix = '[' + str(ectx) + ']' + ctx_prefix = '[' + str(ectx) + '] ' if file_context is not None: - ctx_prefix += ' ' + str(file_context) + ctx_prefix += str(file_context) + ': ' - message = ctx_prefix + ': ' + message + message = ctx_prefix + message # construct message prefix ty_prefix = '[' + log_type + ']' diff --git a/tests/unit/execute/modify_test.py b/tests/unit/execute/modify_test.py index e531268..3a698db 100644 --- a/tests/unit/execute/modify_test.py +++ b/tests/unit/execute/modify_test.py @@ -188,7 +188,7 @@ def mock_chmod(f, mode): assert log['chmod'] is None assert (self.stderr.getvalue() == - ('[WARN] [VERIFICATION]: ' + + ('[WARN] [VERIFICATION] ' + 'FileChmod: Unowned target file "a"\n')), self.stderr.getvalue() @istest @@ -214,7 +214,7 @@ def mock_lchown(f_or_d, uid, gid): act() assert len(lchown_args) == 0 - assert (self.stderr.getvalue() == ('[WARN] [EXECUTION]: ' + + assert (self.stderr.getvalue() == ('[WARN] [EXECUTION] ' + 'DirChown: Cannot Chown as Non-Root User\n')), \ self.stderr.getvalue() @@ -241,7 +241,7 @@ def mock_chmod(f_or_d, mode): act() assert len(chmod_args) == 0 - assert (self.stderr.getvalue() == ('[WARN] [EXECUTION]: ' + + assert (self.stderr.getvalue() == ('[WARN] [EXECUTION] ' + 'DirChmod: Unowned target dir "a"\n')), self.stderr.getvalue() @istest @@ -266,7 +266,7 @@ def mock_lchown(f_or_d, uid, gid): act() assert len(lchown_args) == 0 - assert (self.stderr.getvalue() == ('[WARN] [EXECUTION]: ' + + assert (self.stderr.getvalue() == ('[WARN] [EXECUTION] ' + 'DirChown: Cannot Chown as Non-Root User\n')), \ self.stderr.getvalue() @@ -295,7 +295,7 @@ def mock_chmod(f_or_d, mode): act() assert len(chmod_args) == 0 - assert (self.stderr.getvalue() == ('[WARN] [EXECUTION]: ' + + assert (self.stderr.getvalue() == ('[WARN] [EXECUTION] ' + 'DirChmod: Unowned target dir "a"\n')), self.stderr.getvalue() @istest