Permalink
Browse files

Use RotatingFileHandler to avoid huge logfiles after stresstests.

  • Loading branch information...
1 parent 6994e80 commit 3f45909a2eda09ac33cf96f69a47f7827664b72b @dripton committed Aug 9, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 slugathon/net/Server.py
View
4 slugathon/net/Server.py
@@ -12,6 +12,7 @@
import random
import hashlib
import logging
+from logging.handlers import RotatingFileHandler
from twisted.spread import pb
from twisted.cred.portal import Portal
@@ -58,7 +59,8 @@ def __init__(self, no_passwd, passwd_path, port, log_path):
if not os.path.exists(logdir):
os.makedirs(logdir)
log_path = os.path.join(logdir, "slugathon-server-%d.log" % port)
- file_handler = logging.FileHandler(filename=log_path)
+ file_handler = RotatingFileHandler(filename=log_path,
+ maxBytes=100000000, backupCount=99)
file_handler.setFormatter(formatter)
logging.getLogger().addHandler(file_handler)
console_handler = logging.StreamHandler()

0 comments on commit 3f45909

Please sign in to comment.