summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-11-23 13:48:57 +0100
committerSoren Hansen <soren.hansen@rackspace.com>2010-11-23 13:48:57 +0100
commit89f56207de1ffe2f1f9d5c3cad3ab71ba324d133 (patch)
treea07849c6fdbbd636dce908fb72d5c0dac687f40d
parent2b0e1f330422398e0ec9dcaf9d964d74ec6ca25d (diff)
Add a --logdir flag that will be prepended to the logfile setting. This makes it easier to share a flagfile between multiple workers while still having separate log files.
-rw-r--r--nova/server.py3
-rw-r--r--nova/twistd.py4
2 files changed, 6 insertions, 1 deletions
diff --git a/nova/server.py b/nova/server.py
index cb424caa1..4d0f6e4da 100644
--- a/nova/server.py
+++ b/nova/server.py
@@ -42,6 +42,7 @@ flags.DEFINE_bool('daemonize', False, 'daemonize this process')
# clutter.
flags.DEFINE_bool('use_syslog', True, 'output to syslog when daemonizing')
flags.DEFINE_string('logfile', None, 'log file to output to')
+flags.DEFINE_string('logdir', None, 'directory to keep log files in (will be prepended to $logfile)')
flags.DEFINE_string('pidfile', None, 'pid file to output to')
flags.DEFINE_string('working_directory', './', 'working directory...')
flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run')
@@ -119,6 +120,8 @@ def daemonize(args, name, main):
else:
if not FLAGS.logfile:
FLAGS.logfile = '%s.log' % name
+ if FLAGS.logdir:
+ FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
logfile = logging.FileHandler(FLAGS.logfile)
logfile.setFormatter(formatter)
logger.addHandler(logfile)
diff --git a/nova/twistd.py b/nova/twistd.py
index 3ec0ff61e..6c6cb955f 100644
--- a/nova/twistd.py
+++ b/nova/twistd.py
@@ -43,7 +43,7 @@ else:
FLAGS = flags.FLAGS
-
+flags.DEFINE_string('logdir', None, 'directory to keep log files in (will be prepended to $logfile)')
class TwistdServerOptions(ServerOptions):
def parseArgs(self, *args):
@@ -246,6 +246,8 @@ def serve(filename):
FLAGS.logfile = '%s.log' % name
elif FLAGS.logfile.endswith('twistd.log'):
FLAGS.logfile = FLAGS.logfile.replace('twistd.log', '%s.log' % name)
+ if FLAGS.logdir:
+ FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
if not FLAGS.prefix:
FLAGS.prefix = name
elif FLAGS.prefix.endswith('twisted'):