Add oslo.log and use its config options by default
This patch introduces oslo.log as the new dependency and modifies the configuration to use its options by default. Options can be configured through the generated config file. Change-Id: Iad9ccc5a521ffc49fe813a90ab0ce4997db707d1 Signed-off-by: Taku Fukushima <f.tac.mac@gmail.com> Closes-Bug: #1569672
This commit is contained in:
parent
01e4123988
commit
409cffac1d
@ -17,6 +17,7 @@ Routines for configuring Kuryr
|
||||
import os
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
||||
from kuryr._i18n import _
|
||||
from kuryr import version
|
||||
@ -50,8 +51,6 @@ core_opts = [
|
||||
cfg.StrOpt('global_default_address_space',
|
||||
default='global_scope',
|
||||
help=_('The default neutron global address-scope name.')),
|
||||
cfg.BoolOpt('debug', default=True,
|
||||
help=_('Enable or Disable debug mode for kuryr server.'))
|
||||
]
|
||||
neutron_opts = [
|
||||
cfg.StrOpt('neutron_uri',
|
||||
@ -99,6 +98,9 @@ CONF.register_opts(neutron_opts, group='neutron_client')
|
||||
CONF.register_opts(keystone_opts, group='keystone_client')
|
||||
CONF.register_opts(binding_opts, 'binding')
|
||||
|
||||
# Setting oslo.log options for logging.
|
||||
log.register_options(CONF)
|
||||
|
||||
|
||||
def init(args, **kwargs):
|
||||
cfg.CONF(args=args, project='kuryr',
|
||||
|
@ -17,15 +17,20 @@ __all__ = [
|
||||
import copy
|
||||
import itertools
|
||||
|
||||
import kuryr.common.config
|
||||
from oslo_log import _options
|
||||
|
||||
from kuryr.common import config
|
||||
|
||||
|
||||
_core_opts_with_logging = config.core_opts
|
||||
_core_opts_with_logging += _options.logging_cli_opts
|
||||
_core_opts_with_logging += _options.generic_log_opts
|
||||
|
||||
_kuryr_opts = [
|
||||
(None, list(itertools.chain(
|
||||
kuryr.common.config.core_opts))),
|
||||
('neutron_client', kuryr.common.config.neutron_opts),
|
||||
('keystone_client', kuryr.common.config.keystone_opts),
|
||||
('binding', kuryr.common.config.binding_opts),
|
||||
(None, list(itertools.chain(_core_opts_with_logging))),
|
||||
('neutron_client', config.neutron_opts),
|
||||
('keystone_client', config.keystone_opts),
|
||||
('binding', config.binding_opts),
|
||||
]
|
||||
|
||||
|
||||
|
@ -10,9 +10,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
|
||||
def start():
|
||||
from kuryr.common import config
|
||||
@ -23,6 +24,6 @@ def start():
|
||||
from kuryr import controllers
|
||||
controllers.check_for_neutron_ext_support()
|
||||
app.debug = config.CONF.debug
|
||||
app.logger.addHandler(logging.StreamHandler(sys.stdout))
|
||||
app.logger.setLevel(getattr(logging, config.CONF.log_level))
|
||||
|
||||
log.setup(config.CONF, 'Kuryr')
|
||||
app.run("0.0.0.0", port)
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from neutronclient.common import exceptions as n_exceptions
|
||||
@ -33,8 +32,6 @@ class ConfigurationTest(base.TestKuryrBase):
|
||||
self.assertEqual('http://127.0.0.1:2377',
|
||||
config.CONF.kuryr_uri)
|
||||
|
||||
self.assertEqual(True, config.CONF.debug)
|
||||
|
||||
self.assertEqual('http://127.0.0.1:9696',
|
||||
config.CONF.neutron_client.neutron_uri)
|
||||
|
||||
@ -52,10 +49,3 @@ class ConfigurationTest(base.TestKuryrBase):
|
||||
self.mox.ReplayAll()
|
||||
ex = exceptions.MandatoryApiMissing
|
||||
self.assertRaises(ex, controllers.check_for_neutron_ext_support)
|
||||
|
||||
def test_log_level(self):
|
||||
controllers.app.logger.setLevel(
|
||||
getattr(logging, config.CONF.log_level))
|
||||
log_level = logging.getLevelName(
|
||||
controllers.app.logger.getEffectiveLevel())
|
||||
self.assertEqual(log_level, config.CONF.log_level)
|
||||
|
@ -8,6 +8,7 @@ Flask<1.0,>=0.10 # BSD
|
||||
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
|
||||
netaddr!=0.7.16,>=0.7.12 # BSD
|
||||
oslo.concurrency>=3.5.0 # Apache-2.0
|
||||
oslo.log>=1.14.0 # Apache-2.0
|
||||
oslo.serialization>=1.10.0 # Apache-2.0
|
||||
oslo.utils>=3.5.0 # Apache-2.0
|
||||
python-neutronclient>=4.1.1 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user