Commit c1f587a7 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Rotate the logs

parent a341dbec
......@@ -10,7 +10,11 @@ log_format: %(name)s@%(module)s:%(lineno)s %(asctime)s %(levelname)s %(message)s
; Severity of the logs. One of TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL
log_severity: TRACE
; Where to log. - means stderr.
log_file: -
log_file: master.log
; Maximum size of log file (in bytes)
log_file_size: 134217728
; Maximum number of backup log files when rotated
log_file_count: 5
; The plugins to load follow. Each name is the class to load and instantiate.
......
#!/usr/bin/python
#!/usr/bin/python2
from twisted.internet import reactor
from twisted.internet.endpoints import TCP6ServerEndpoint
import log_extra
import logging
import logging.handlers
from client import ClientFactory
from plugin import Plugins
import master_config
......@@ -15,10 +16,9 @@ if severity == 'TRACE':
else:
severity = getattr(logging, severity)
log_file = master_config.get('log_file')
if log_file == '-':
logging.basicConfig(level=severity, format=master_config.get('log_format'))
else:
logging.basicConfig(level=severity, format=master_config.get('log_format'), filename=log_file)
logging.basicConfig(level=severity, format=master_config.get('log_format'))
if log_file != '-':
logging.getLogger().addHandler(logging.handlers.RotatingFileHandler(log_file, maxBytes=int(master_config.get('log_file_size')), backupCount=int(master_config.get('log_file_count'))))
loaded_plugins = {}
plugins = Plugins()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment