commit 9c0cd2e2d0c4ecccb739bbde9beb240318d93d63
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Tue Jul 10 10:41:42 2012 +0200
Fix logging, debug messages was not logged
log.py | 6 +++++-
virt-who.py | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/log.py b/log.py
index 87fc94a..e415001 100644
--- a/log.py
+++ b/log.py
@@ -26,6 +26,7 @@ import sys
def getLogger(debug, background):
logger = logging.getLogger("rhsm-app")
+ logger.setLevel(logging.DEBUG)
path = '/var/log/rhsm/rhsm.log'
try:
@@ -38,7 +39,10 @@ def getLogger(debug, background):
try:
fileHandler = logging.handlers.RotatingFileHandler(path, maxBytes=0x100000,
backupCount=5)
fileHandler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s]
@%(filename)s:%(lineno)d - %(message)s'))
- fileHandler.setLevel(logging.DEBUG)
+ if debug:
+ fileHandler.setLevel(logging.DEBUG)
+ else:
+ fileHandler.setLevel(logging.WARNING)
logger.addHandler(fileHandler)
except Exception, e:
sys.stderr.write("Unable to log to %s: %s\n" % (path, e))
diff --git a/virt-who.py b/virt-who.py
index 8dc33bb..ed04792 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -317,12 +317,12 @@ if __name__ == '__main__':
if env in ["1", "true"]:
options.debug = True
- logger = log.getLogger(options.debug, options.background)
-
env = os.getenv("VIRTWHO_BACKGROUND", "0").strip().lower()
if env in ["1", "true"]:
options.background = True
+ logger = log.getLogger(options.debug, options.background)
+
env = os.getenv("VIRTWHO_ONE_SHOT", "0").strip().lower()
if env in ["1", "true"]:
options.oneshot = True
Show replies by date