This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davy.zhang
Recipients davy.zhang
Date 2010-05-19.10:56:42
SpamBayes Score 0.0017129608
Marked as misclassified No
Message-id <1274266604.24.0.270763712229.issue8764@psf.upfronthosting.co.za>
In-reply-to
Content
the function below is used to determine the proper file name of the next log file. But the question is if I set a large number of self.backupCount like 10000000, it will take too long to calculate the right file name. I think it could be a better way to do this instead of finding from the end.

    def doRollover(self):
        """
        Do a rollover, as described in __init__().
        """

        self.stream.close()
        if self.backupCount > 0:
            for i in range(self.backupCount - 1, 0, -1):
                sfn = "%s.%d" % (self.baseFilename, i)
                dfn = "%s.%d" % (self.baseFilename, i + 1)
                if os.path.exists(sfn):
                    #print "%s -> %s" % (sfn, dfn)
                    if os.path.exists(dfn):
                        os.remove(dfn)
                    os.rename(sfn, dfn)
            dfn = self.baseFilename + ".1"
            if os.path.exists(dfn):
                os.remove(dfn)
            os.rename(self.baseFilename, dfn)
            #print "%s -> %s" % (self.baseFilename, dfn)
        self.mode = 'w'
        self.stream = self._open()
History
Date User Action Args
2010-05-19 10:56:44davy.zhangsetrecipients: + davy.zhang
2010-05-19 10:56:44davy.zhangsetmessageid: <1274266604.24.0.270763712229.issue8764@psf.upfronthosting.co.za>
2010-05-19 10:56:42davy.zhanglinkissue8764 messages
2010-05-19 10:56:42davy.zhangcreate