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.

This commit is contained in:
Soren Hansen
2010-11-23 13:48:57 +01:00
parent 8a86c10f39
commit afefc42a87
2 changed files with 6 additions and 1 deletions

View File

@@ -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'):