Merge lp:~soren/nova/logdir-flag into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Soren Hansen
Approved revision: 413
Merged at revision: 415
Proposed branch: lp:~soren/nova/logdir-flag
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 43 lines (+8/-0)
2 files modified
nova/server.py (+4/-0)
nova/twistd.py (+4/-0)
To merge this branch: bzr merge lp:~soren/nova/logdir-flag
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Eric Day (community) Approve
Review via email: mp+41590@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Eric Day (eday) wrote :

lgtm!

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

yup, lgtm. one more thing that should be going into openstack.common :)

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

The attempt to merge lp:~soren/nova/logdir-flag into lp:nova failed. Below is the output from the failed tests.

nova/server.py:45:80: E501 line too long (102 characters)
flags.DEFINE_string('logdir', None, 'directory to keep log files in (will be prepended to $logfile)')
                                                                               ^
    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to have
    several windows side-by-side. The default wrapping on such devices looks
    ugly. Therefore, please limit all lines to a maximum of 79 characters.
    For flowing long blocks of text (docstrings or comments), limiting the
    length to 72 characters is recommended.
nova/twistd.py:46:80: E501 line too long (102 characters)
flags.DEFINE_string('logdir', None, 'directory to keep log files in (will be prepended to $logfile)')
                                                                               ^
    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to have
    several windows side-by-side. The default wrapping on such devices looks
    ugly. Therefore, please limit all lines to a maximum of 79 characters.
    For flowing long blocks of text (docstrings or comments), limiting the
    length to 72 characters is recommended.
nova/twistd.py:48:1: E302 expected 2 blank lines, found 1
class TwistdServerOptions(ServerOptions):
^
    Separate top-level function and class definitions with two blank lines.

    Method definitions inside a class are separated by a single blank line.

    Extra blank lines may be used (sparingly) to separate groups of related
    functions. Blank lines may be omitted between a bunch of related
    one-liners (e.g. a set of dummy implementations).

    Use blank lines in functions, sparingly, to indicate logical sections.

    Okay: def a():\n pass\n\n\ndef b():\n pass
    Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass

    E301: class Foo:\n b = 0\n def bar():\n pass
    E302: def a():\n pass\n\ndef b(n):\n pass
    E303: def a():\n pass\n\n\n\ndef b(n):\n pass
    E303: def a():\n\n\n\n pass
    E304: @decorator\n\ndef a():\n pass

lp:~soren/nova/logdir-flag updated
413. By Soren Hansen

Address PEP8 complaints.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/server.py'
2--- nova/server.py 2010-10-21 18:49:51 +0000
3+++ nova/server.py 2010-11-23 20:54:09 +0000
4@@ -42,6 +42,8 @@
5 # clutter.
6 flags.DEFINE_bool('use_syslog', True, 'output to syslog when daemonizing')
7 flags.DEFINE_string('logfile', None, 'log file to output to')
8+flags.DEFINE_string('logdir', None, 'directory to keep log files in '
9+ '(will be prepended to $logfile)')
10 flags.DEFINE_string('pidfile', None, 'pid file to output to')
11 flags.DEFINE_string('working_directory', './', 'working directory...')
12 flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run')
13@@ -119,6 +121,8 @@
14 else:
15 if not FLAGS.logfile:
16 FLAGS.logfile = '%s.log' % name
17+ if FLAGS.logdir:
18+ FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
19 logfile = logging.FileHandler(FLAGS.logfile)
20 logfile.setFormatter(formatter)
21 logger.addHandler(logfile)
22
23=== modified file 'nova/twistd.py'
24--- nova/twistd.py 2010-10-21 18:49:51 +0000
25+++ nova/twistd.py 2010-11-23 20:54:09 +0000
26@@ -43,6 +43,8 @@
27
28
29 FLAGS = flags.FLAGS
30+flags.DEFINE_string('logdir', None, 'directory to keep log files in '
31+ '(will be prepended to $logfile)')
32
33
34 class TwistdServerOptions(ServerOptions):
35@@ -246,6 +248,8 @@
36 FLAGS.logfile = '%s.log' % name
37 elif FLAGS.logfile.endswith('twistd.log'):
38 FLAGS.logfile = FLAGS.logfile.replace('twistd.log', '%s.log' % name)
39+ if FLAGS.logdir:
40+ FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
41 if not FLAGS.prefix:
42 FLAGS.prefix = name
43 elif FLAGS.prefix.endswith('twisted'):