]> granicus.if.org Git - python/commitdiff
Backported SysLogHandler fix for issue #7077.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 15 Jul 2010 21:40:13 +0000 (21:40 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 15 Jul 2010 21:40:13 +0000 (21:40 +0000)
Lib/logging/handlers.py

index 31352ad1c7d476faea706212bcc7b46175eca1bc..82c418b368d10cd5fb49aac875c394665f712b34 100644 (file)
@@ -202,7 +202,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
 
         self.extMatch = re.compile(self.extMatch, re.ASCII)
         self.interval = self.interval * interval # multiply by units requested
-        self.rolloverAt = self.computeRollover(int(time.time()))
+        if os.path.exists(filename):
+            t = os.stat(filename)[ST_MTIME]
+        else:
+            t = int(time.time())
+        self.rolloverAt = self.computeRollover(t)
 
     def computeRollover(self, currentTime):
         """
@@ -774,6 +778,9 @@ class SysLogHandler(logging.Handler):
             self.encodePriority(self.facility,
                                 self.mapPriority(record.levelname)),
                                 msg)
+        msg = msg.encode('utf-8')
+        if codecs:
+            msg = codecs.BOM_UTF8 + msg
         try:
             if self.unixsocket:
                 try: