diff options
author | YAMADA Hideki <yamada.hideki@po.ntts.co.jp> | 2012-11-27 16:06:50 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-11-28 08:02:15 +0900 |
commit | c5c7dc9cfe1e44199cb33158a67416abbd3bbf0f (patch) | |
tree | c4a77c248a62f64495d6deec4a94187a4622d779 | |
parent | c7d4aa74757684a58a84d3997d454d32680a4c92 (diff) |
ryu/log: bugfix
$ ryu-manager --log_file $HOME/ryu.log
Traceback (most recent call last):
(...)
File "/usr/local/lib/python2.7/dist-packages/ryu-1.1-py2.7.egg/ryu/log.py", line 74, in init_log
logging.addHandler(logging.handlers.WatchedFileHandler(log_file))
AttributeError: 'module' object has no attribute 'addHandler'
$ ryu-manager --log_file $HOME/ryu.log
Traceback (most recent call last):
(...)
File "/usr/local/lib/python2.7/dist-packages/ryu-1.4-py2.7.egg/ryu/log.py", line 74, in init_log
log.addHandler(logging.handlers.WatchedFileHandler(log_file))
AttributeError: 'module' object has no attribute 'handlers'
$ ryu-manager --log_file $HOME/ryu.log
Traceback (most recent call last):
(...)
File "/usr/local/lib/python2.7/dist-packages/ryu-1.4-py2.7.egg/ryu/log.py", line 76, in init_log
mode = int(FLAGS.log_file_mnode, 8)
File "/usr/local/lib/python2.7/dist-packages/gflags.py", line 810, in __getattr__
raise AttributeError(name)
AttributeError: log_file_mnode
$ ryu-manager --log_dir $HOME/log/
Traceback (most recent call last):
(...)
File "/usr/local/lib/python2.7/dist-packages/ryu-1.4-py2.7.egg/ryu/log.py", line 54, in _get_log_file
return os.path.join(FLAGS.logdir,
File "/usr/local/lib/python2.7/dist-packages/gflags.py", line 810, in __getattr__
raise AttributeError(name)
AttributeError: logdir
Signed-off-by: YAMADA Hideki <yamada.hideki@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/log.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -17,6 +17,7 @@ import gflags import inspect import logging +import logging.handlers import os import sys @@ -50,7 +51,7 @@ def _get_log_file(): if FLAGS.log_file: return FLAGS.log_file if FLAGS.log_dir: - return os.path.join(FLAGS.logdir, + return os.path.join(FLAGS.log_dir, os.path.basename(inspect.stack()[-1][1])) + '.log' return None @@ -71,8 +72,8 @@ def init_log(): log_file = _get_log_file() if log_file is not None: - logging.addHandler(logging.handlers.WatchedFileHandler(log_file)) - mode = int(FLAGS.log_file_mnode, 8) + log.addHandler(logging.handlers.WatchedFileHandler(log_file)) + mode = int(FLAGS.log_file_mode, 8) os.chmod(log_file, mode) if FLAGS.verbose: |