summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>2010-06-02 16:44:15 +0200
committerAlexandre Fayolle <alexandre.fayolle@logilab.fr>2010-06-02 16:44:15 +0200
commit72fd31a8ff029f1a3ee0c5d4f5f93c443c703338 (patch)
tree8296e7b3edf656186d04babb71c6eb2247a65142
parent0f2b6209a5582cd38f3f5d3ca9442629036f5ebf (diff)
parent4abf86900be5062abaec77dc01d101dfe98b718d (diff)
downloadlogilab-common-72fd31a8ff029f1a3ee0c5d4f5f93c443c703338.tar.gz
merge changes made on site
-rw-r--r--logging_ext.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/logging_ext.py b/logging_ext.py
index 71d5f87..e86945b 100644
--- a/logging_ext.py
+++ b/logging_ext.py
@@ -103,7 +103,8 @@ 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,
+ rotation_parameters=None):
"""init the log service"""
if os.environ.get('APYCOT_ROOT'):
logthreshold = logging.CRITICAL
@@ -120,7 +121,12 @@ def init_log(debug=False, syslog=False, logthreshold=None, logfile=None,
handler = logging.StreamHandler()
else:
try:
- handler = logging.FileHandler(logfile)
+ if rotation_parameters is None:
+ handler = logging.FileHandler(logfile)
+ else:
+ from logging.handlers import TimedRotatingFileHandler
+ handler = TimedRotatingFileHandler(logfile,
+ **rotation_parameters)
except IOError:
handler = logging.StreamHandler()
if logthreshold is None: