logging settings stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Wed, 02 Jun 2010 16:25:12 +0000
branchstable
changeset 5640 8a6d14f4fb9d
parent 5639 4acb860159e4
child 5641 4c1d0e80a376
child 5642 6a90357b9769
logging settings * document helpful log format when dealing with MT issues * on Win32, use a logrotate equivalent so that logs get a bit lighter (requires updates logilab.common)
cwconfig.py
--- a/cwconfig.py	Wed Jun 02 16:12:18 2010 +0000
+++ b/cwconfig.py	Wed Jun 02 16:25:12 2010 +0000
@@ -291,7 +291,9 @@
     name = None
     # log messages format (see logging module documentation for available keys)
     log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
-    # nor remove appobjects based on unused interface
+    # the format below can be useful to debug multi thread issues:
+    # log_format = '%(asctime)s - [%(threadName)s] (%(name)s) %(levelname)s: %(message)s'
+    # nor remove appobjects based on unused interface [???]
     cleanup_interface_sobjects = True
     # debug mode
     debugmode = False
@@ -689,7 +691,17 @@
             else:
                 logthreshold = self['log-threshold']
         self.debugmode = debug
-        init_log(debug, syslog, logthreshold, logfile, self.log_format)
+        if sys.platform == 'win32':
+            # no logrotate on win32, so use logging rotation facilities
+            # for now, hard code weekly rotation every sunday, and 52 weeks kept
+            # idea: make this configurable?
+            init_log(debug, syslog, logthreshold, logfile, self.log_format,
+                     rotation_parameters={'when': 'W7', # every sunday
+                                          'interval': 1,
+                                          'backupCount': 52,                                          
+                                         })
+        else:
+            init_log(debug, syslog, logthreshold, logfile, self.log_format)
         # configure simpleTal logger
         logging.getLogger('simpleTAL').setLevel(logging.ERROR)