[openstack-dev] oslo_log/oslo_config initialization

Qiming Teng tengqim at linux.vnet.ibm.com
Wed Jan 21 11:18:52 UTC 2015


On Wed, Jan 21, 2015 at 12:27:15PM +0200, Denis Makogon wrote:
> On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng <tengqim at linux.vnet.ibm.com>
> wrote:
> 
> > Hi,
> >
> > In the oslo_log 0.1.0 release, the setup() function demands for a conf
> > parameter, but I have failed to find any hint about setting this up.
> >
> > The problem is cfg.CONF() returns None, so the following code fails:
> >
> >   conf = cfg.CONF(name='prog', project='project')
> >   # conf is always None here, so the following call fails
> >   log.setup(conf, 'project')
> >
> > Another attempt also failed, because it cannot find any options:
> >
> >   log.setup(cfg.CONF, 'project')
> >
> > Any hint or sample code to setup logging if I'm abandoning the log
> > module from oslo.incubator?
> >
> >
> You might take a look at
> https://github.com/openstack/oslo.log/blob/master/oslo_log/_options.py
> Those options are what oslo_log expects to find in service configuration
> files.

Yes. The configuration file I have them. In the usage.rst file I found
here: https://review.openstack.org/#/c/147312/1/doc/source/usage.rst

The 'changes to app initiliaztion' section is very confusing. I still
need a configuration object, so I did it:

  cfg.CONF(name='prog', project='project')

Then I explicitly register the logging options as suggested:

  log.register_options(cfg.CONF)


Finally, I pass the same object to setup, as suggested:

  log.setup(cfg.CONF, 'prog')

Then I'm getting the following error:

Traceback (most recent call last):
  File "/usr/bin/test-engine", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/opt/stack/proj/bin/test-engine", line 50, in <module>
    log.register_options(cfg.CONF)
  File "/usr/lib/python2.6/site-packages/oslo_log/log.py", line 185, in register_options
    conf.register_cli_opts(_options.common_cli_opts)
  File "/usr/lib/python2.6/site-packages/oslo_config/cfg.py", line 1679, in __inner
    result = f(self, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/oslo_config/cfg.py", line 1860, in register_cli_opts
    self.register_cli_opt(opt, group, clear_cache=False)
  File "/usr/lib/python2.6/site-packages/oslo_config/cfg.py", line 1683, in __inner
    return f(self, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/oslo_config/cfg.py", line 1852, in register_cli_opt
    raise ArgsAlreadyParsedError("cannot register CLI option")
oslo_config.cfg.ArgsAlreadyParsedError: arguments already parsed: cannot register CLI option

> > Thanks!
> >
> > Regards,
> >   Qiming
> >
> >
> > __________________________________________________________________________
> > OpenStack Development Mailing List (not for usage questions)
> > Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> >
> 
> 
> Kind regards,
> Denis M.

> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list