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__), '../'),
"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',
'sqlite:///$state_path/nova.sqlite',

View File

@@ -28,9 +28,11 @@ It also allows setting of formatting information through flags.
import cStringIO
import inspect
import json
import logging
import logging.handlers
import os
import sys
import traceback
@@ -123,8 +125,13 @@ def basicConfig():
syslog = SysLogHandler(address='/dev/log')
syslog.setFormatter(_formatter)
logging.root.addHandler(syslog)
if FLAGS.logfile or FLAGS.logdir:
if FLAGS.logfile:
logfile = FileHandler(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)
logging.root.addHandler(logfile)

View File

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