Merge "Don't log to stdout when log_dir is set"
This commit is contained in:
commit
f47287fc64
@ -475,7 +475,7 @@ def _setup_logging_from_conf():
|
|||||||
streamlog = ColorHandler()
|
streamlog = ColorHandler()
|
||||||
log_root.addHandler(streamlog)
|
log_root.addHandler(streamlog)
|
||||||
|
|
||||||
elif not CONF.log_file:
|
elif not logpath:
|
||||||
# pass sys.stdout as a positional argument
|
# pass sys.stdout as a positional argument
|
||||||
# python2.6 calls the argument strm, in 2.7 it's stream
|
# python2.6 calls the argument strm, in 2.7 it's stream
|
||||||
streamlog = logging.StreamHandler(sys.stdout)
|
streamlog = logging.StreamHandler(sys.stdout)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
@ -437,6 +438,16 @@ class LogConfigOptsTestCase(test.BaseTestCase):
|
|||||||
self.CONF(['--log-file', log_file])
|
self.CONF(['--log-file', log_file])
|
||||||
self.assertEqual(self.CONF.log_file, log_file)
|
self.assertEqual(self.CONF.log_file, log_file)
|
||||||
|
|
||||||
|
def test_log_dir_handlers(self):
|
||||||
|
log_dir = tempfile.mkdtemp()
|
||||||
|
self.CONF(['--log-dir', log_dir])
|
||||||
|
self.CONF.set_default('use_stderr', False)
|
||||||
|
log._setup_logging_from_conf()
|
||||||
|
logger = log._loggers[None].logger
|
||||||
|
self.assertEqual(1, len(logger.handlers))
|
||||||
|
self.assertIsInstance(logger.handlers[0],
|
||||||
|
logging.handlers.WatchedFileHandler)
|
||||||
|
|
||||||
def test_logfile_deprecated(self):
|
def test_logfile_deprecated(self):
|
||||||
logfile = '/some/other/path/foo-bar.log'
|
logfile = '/some/other/path/foo-bar.log'
|
||||||
self.CONF(['--logfile', logfile])
|
self.CONF(['--logfile', logfile])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user