diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-12-04 15:15:26 +0000 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-12-04 15:15:26 +0000 |
commit | 603d521bbdd0a02a418e6d788892a9c6e48f5b8a (patch) | |
tree | e787d0afa1e951794f1d0388dc4ed71eea933c7b /pykolab | |
parent | 3ed1abf698a392790637ef6797c15e10c7256077 (diff) | |
download | pykolab-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.
Diffstat (limited to 'pykolab')
-rw-r--r-- | pykolab/logger.py | 49 |
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) |