Resurrect logdir option.

This commit is contained in:
Soren Hansen
2011-02-14 23:19:15 +01:00
parent a56b7e4c27
commit 696b52b7bb
3 changed files with 11 additions and 4 deletions

View File

@@ -282,6 +282,8 @@ DEFINE_integer('auth_token_ttl', 3600, 'Seconds for auth tokens to linger')
DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../'), DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../'),
"Top-level directory for maintaining nova's state") "Top-level directory for maintaining nova's state")
DEFINE_string('logdir', None, 'output to a per-service log file in named '
'directory')
DEFINE_string('sql_connection', DEFINE_string('sql_connection',
'sqlite:///$state_path/nova.sqlite', 'sqlite:///$state_path/nova.sqlite',

View File

@@ -28,9 +28,11 @@ It also allows setting of formatting information through flags.
import cStringIO import cStringIO
import inspect
import json import json
import logging import logging
import logging.handlers import logging.handlers
import os
import sys import sys
import traceback import traceback
@@ -123,8 +125,13 @@ def basicConfig():
syslog = SysLogHandler(address='/dev/log') syslog = SysLogHandler(address='/dev/log')
syslog.setFormatter(_formatter) syslog.setFormatter(_formatter)
logging.root.addHandler(syslog) logging.root.addHandler(syslog)
if FLAGS.logfile: if FLAGS.logfile or FLAGS.logdir:
logfile = FileHandler(FLAGS.logfile) if FLAGS.logfile:
logfile = FLAGS.logfile
else:
binary = os.path.basename(inspect.stack()[-1][1])
logpath = '%s.log' % (os.path.join(FLAGS.logdir, binary),)
logfile = FileHandler(logpath)
logfile.setFormatter(_formatter) logfile.setFormatter(_formatter)
logging.root.addHandler(logfile) logging.root.addHandler(logfile)

View File

@@ -43,8 +43,6 @@ else:
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
flags.DEFINE_string('logdir', None, 'directory to keep log files in '
'(will be prepended to $logfile)')
class TwistdServerOptions(ServerOptions): class TwistdServerOptions(ServerOptions):