Rotating file log

This commit is contained in:
Ruben van de Ven 2019-11-12 14:35:36 +01:00
parent f15126d0e4
commit 8f7c31a9e5

View file

@ -39,8 +39,20 @@ if __name__ == '__main__':
) )
logger = logging.getLogger("hugvey") logger = logging.getLogger("hugvey")
logFileHandler = logging.handlers.RotatingFileHandler(
'./recordings/server.log',
maxBytes=1024*512,
backupCount=5
)
logFileHandler.setFormatter(logging.Formatter(
fmt="%(asctime)s %(name)s[%(process)d,%(threadName)s] %(levelname)s %(message)s"
))
logger.addHandler(logFileHandler)
# logger.setLevel(1) # to send all records to cutelog # logger.setLevel(1) # to send all records to cutelog
socket_handler = logging.handlers.SocketHandler('127.0.0.1', 19996) # default listening address socket_handler = logging.handlers.SocketHandler('127.0.0.1', 19996) # default listening address
socket_handler.setLevel(logging.DEBUG)
logger.addHandler(socket_handler) logger.addHandler(socket_handler)
logger.info("Start server") logger.info("Start server")