summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-12-04 15:15:26 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-12-04 15:15:26 +0000
commit603d521bbdd0a02a418e6d788892a9c6e48f5b8a (patch)
treee787d0afa1e951794f1d0388dc4ed71eea933c7b
parent3ed1abf698a392790637ef6797c15e10c7256077 (diff)
downloadpykolab-603d521bbdd0a02a418e6d788892a9c6e48f5b8a.tar.gz
Only use sys.argv if they are indeed specified
Suppress the messages about not being able to chown our log file. What we are actually interested in is whether we can write to it.
-rw-r--r--pykolab/logger.py49
1 files changed, 24 insertions, 25 deletions
diff --git a/pykolab/logger.py b/pykolab/logger.py
index 7bd0bd4..c812261 100644
--- a/pykolab/logger.py
+++ b/pykolab/logger.py
@@ -38,28 +38,29 @@ class Logger(logging.Logger):
fork = False
loglevel = logging.CRITICAL
- for arg in sys.argv:
- if debuglevel == -1:
- debuglevel = int(arg)
- loglevel = logging.DEBUG
- break
-
- if '-d' == arg:
- debuglevel = -1
- continue
-
- if '-l' == arg:
- loglevel = -1
- continue
-
- if '--fork' == arg:
- fork = True
-
- if loglevel == -1:
- if hasattr(logging,arg.upper()):
- loglevel = getattr(logging,arg.upper())
- else:
+ if hasattr(sys, 'argv'):
+ for arg in sys.argv:
+ if debuglevel == -1:
+ debuglevel = int(arg)
loglevel = logging.DEBUG
+ break
+
+ if '-d' == arg:
+ debuglevel = -1
+ continue
+
+ if '-l' == arg:
+ loglevel = -1
+ continue
+
+ if '--fork' == arg:
+ fork = True
+
+ if loglevel == -1:
+ if hasattr(logging,arg.upper()):
+ loglevel = getattr(logging,arg.upper())
+ else:
+ loglevel = logging.DEBUG
def __init__(self, *args, **kw):
if kw.has_key('name'):
@@ -102,10 +103,7 @@ class Logger(logging.Logger):
)
os.chmod(self.logfile, 0660)
except:
- print >> sys.stderr, \
- _("Could not change the ownership of log file %s") % (
- self.logfile
- )
+ pass
# Make sure the log file exists
try:
@@ -144,5 +142,6 @@ class Logger(logging.Logger):
if level <= self.debuglevel:
# TODO: Not the way it's supposed to work!
self.log(logging.DEBUG, '[%d]: %s' % (os.getpid(),msg))
+
logging.setLoggerClass(Logger)