#encoding=utf8
# 按天生成文件

import logging
import time

from logging.handlers import TimedRotatingFileHandler

#----------------------------------------------------------------------  
if __name__ == "__main__":
    logFilePath = "timed_test.log"
    logger = logging.getLogger("YouLoggerName")
    logger.setLevel(logging.INFO)

    handler = TimedRotatingFileHandler(logFilePath,
                                       when="d",
                                       interval=1,
                                       backupCount=7)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    handler.setFormatter(formatter)
    handler.setLevel(logging.INFO)
    logger.addHandler(handler)


    for i in range(6):
        logger.info("This is a info!")
        logger.debug("This is a debug!")
        # time.sleep(61)  
[((12, 13, 12, 47), 'logging.getLogger', 'logging.getLogger', ({(12, 31, 12, 46): '"""YouLoggerName"""'}, {}), "('YouLoggerName')", False, 'import logging\n'), ((15, 14, 18, 53), 'logging.handlers.TimedRotatingFileHandler', 'TimedRotatingFileHandler', (), '', False, 'from logging.handlers import TimedRotatingFileHandler\n'), ((19, 16, 19, 89), 'logging.Formatter', 'logging.Formatter', ({(19, 34, 19, 88): '"""%(asctime)s - %(name)s - %(levelname)s - %(message)s"""'}, {}), "('%(asctime)s - %(name)s - %(levelname)s - %(message)s')", False, 'import logging\n')]