summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2010-08-10 14:13:13 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2010-08-10 14:13:13 +0200
commit1b737daf6d272a665b2f1ef558d5d5acad0260db (patch)
tree92a7caf0dc62a7648d7cb508a366e5f90cbfe0d5
parent0b565571dc37df79db326273e0d47cb52c2d7bfe (diff)
downloadlogilab-common-1b737daf6d272a665b2f1ef558d5d5acad0260db.tar.gz
new init_log now accept a fmt argument (eg formatter) to use when the colorized formatter should not be used
-rw-r--r--logging_ext.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/logging_ext.py b/logging_ext.py
index eb21eb2..bf5447b 100644
--- a/logging_ext.py
+++ b/logging_ext.py
@@ -72,7 +72,7 @@ class ColorFormatter(logging.Formatter):
else:
for cf in self.colorfilters:
color = cf(record)
- if color:
+ if color:
return colorize_ansi(msg, color)
return msg
@@ -98,7 +98,7 @@ LOG_FORMAT = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def init_log(debug=False, syslog=False, logthreshold=None, logfile=None,
- logformat=LOG_FORMAT, logdateformat=LOG_DATE_FORMAT,
+ logformat=LOG_FORMAT, logdateformat=LOG_DATE_FORMAT, fmt=None,
rotation_parameters=None):
"""init the log service"""
if os.environ.get('APYCOT_ROOT'):
@@ -120,7 +120,7 @@ def init_log(debug=False, syslog=False, logthreshold=None, logfile=None,
handler = logging.FileHandler(logfile)
else:
from logging.handlers import TimedRotatingFileHandler
- handler = TimedRotatingFileHandler(logfile,
+ handler = TimedRotatingFileHandler(logfile,
**rotation_parameters)
except IOError:
handler = logging.StreamHandler()
@@ -144,7 +144,7 @@ def init_log(debug=False, syslog=False, logthreshold=None, logfile=None,
if 'kick' in record.message:
return 'red'
fmt.colorfilters.append(col_fact)
- else:
+ elif fmt is None:
fmt = logging.Formatter(logformat, logdateformat)
handler.setFormatter(fmt)
return handler