Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
Enable log file name with pid
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Truemper committed Feb 25, 2014
1 parent 28e0999 commit d518df9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -53,4 +53,4 @@ docs/html
######
# logs
######
root.log*
root*.log*
2 changes: 2 additions & 0 deletions supercell/logging.py
Expand Up @@ -20,6 +20,7 @@

from logging import Formatter
from logging.handlers import TimedRotatingFileHandler
import os


class SupercellLoggingHandler(TimedRotatingFileHandler):
Expand All @@ -28,6 +29,7 @@ class SupercellLoggingHandler(TimedRotatingFileHandler):

def __init__(self, logfile):
'''Initialize the :class:`TimedRotatingFileHandler`.'''
logfile = logfile % {'pid': os.getpid()}
TimedRotatingFileHandler.__init__(self, logfile, when='d',
interval=1, backupCount=10)
formatter = Formatter(' - '.join(['[%(asctime)s',
Expand Down
6 changes: 4 additions & 2 deletions supercell/service.py
Expand Up @@ -35,7 +35,9 @@
from supercell.logging import SupercellLoggingHandler


define('logfile', default='root.log', help='Filename to store the logs')
define('logfile', default='root-%(pid)s.log',
help='Filename to store the logs. If the name contains "%%(pid)s" ' +
'it will be replaced with the pid.')


define('loglevel', default='INFO', help='Log level')
Expand All @@ -50,7 +52,7 @@
define('socketfd', default=None, help='Filedescriptor used from circus')


define('debug', default=False, help='If set, tornado is started in debug mode')
define('debug', default=False, help='If set, Tornado is started in debug mode')


define('show_config_file_order', default=False,
Expand Down

0 comments on commit d518df9

Please sign in to comment.