diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-08-25 09:41:28 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-08-25 09:41:28 +0200 |
commit | c65977e9f6fe07f3377f8c89dc908284c5eef218 (patch) | |
tree | 94ebab9f4a88764faccf5cecf7baed6f5795bab4 /clcommands.py | |
parent | 0fe7bb5192debd747a9ad3b48955feef9711d292 (diff) | |
download | logilab-common-c65977e9f6fe07f3377f8c89dc908284c5eef218.tar.gz |
some logger handling fixes
Diffstat (limited to 'clcommands.py')
-rw-r--r-- | clcommands.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clcommands.py b/clcommands.py index c286052..5761efc 100644 --- a/clcommands.py +++ b/clcommands.py @@ -62,13 +62,13 @@ class CommandLine(dict): def init_log(self): from logilab.common import logging_ext - self.logger = getLogger(self.pgm) - logging_ext.init_log(debug=True, - logformat='%(name)s %(levelname)s: %(message)s') + if self.logger is None: + self.logger = getLogger(self.pgm) + logging_ext.init_log(debug=True, + logformat='%(name)s %(levelname)s: %(message)s') def register(self, cls): self[cls.name] = cls - cls.logger = self.logger def run(self, args): self.init_log() @@ -88,7 +88,7 @@ class CommandLine(dict): except IndexError: self.usage_and_exit(1) try: - command = self[arg]() + command = self[arg](self.logger) except KeyError: print 'ERROR: no %s command' % arg print @@ -165,10 +165,11 @@ class Command(Configuration): def short_description(cls): return cls.description().split('.')[0] - def __init__(self): + def __init__(self, logger): usage = '%%prog %s %s\n\n%s' % (self.name, self.arguments, self.description()) Configuration.__init__(self, usage=usage) + self.logger = logger def check_args(self, args): """check command's arguments are provided""" |