settingsLogin | Registersettings

[openstack-dev] oslo_log/oslo_config initialization

0 votes

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?

Thanks!

Regards,
Qiming

asked Jan 21, 2015 in openstack-dev by Qiming_Teng (7,380 points)   3 9 13
retagged Jan 28, 2015 by admin

15 Responses

0 votes

On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng
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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:

responded Jan 21, 2015 by Denis_Makogon (3,560 points)   3 3
0 votes

On Wed, Jan 21, 2015 at 12:27:15PM +0200, Denis Makogon wrote:
On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng
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
exec(compile(open(file).read(), file, 'exec'))
File "/opt/stack/proj/bin/test-engine", line 50, in
log.registeroptions(cfg.CONF)
File "/usr/lib/python2.6/site-packages/oslo
log/log.py", line 185, in registeroptions
conf.register
cliopts(options.commoncliopts)
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
responded Jan 21, 2015 by Qiming_Teng (7,380 points)   3 9 13
0 votes

On Wed, Jan 21, 2015 at 12:27:15PM +0200, Denis Makogon wrote:
On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng
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.

Okay, my guess is that both osloconfig and oslolog are trying to
registerclioptions. I have to create a configuration object for
oslolog to work, and it means CLI options are registered once.
Later on, when I'm calling log.register
options(), it is conflicting
with previous registration.

So, I'm doubting whether these two packages have been tested together?

Regards,
Qiming

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
responded Jan 21, 2015 by Qiming_Teng (7,380 points)   3 9 13
0 votes

Qiming,

Nova already uses oslo.config. there's a patch against nova to use
oslolog. Doug took the effort to do this so we'd not face issues once
we release oslo
log, so yes, they have been tested together. Please
hop onto #openstack-oslo to debug in real time.

[1] https://review.openstack.org/#/c/147635/

On Wed, Jan 21, 2015 at 8:11 AM, Qiming Teng wrote:
On Wed, Jan 21, 2015 at 12:27:15PM +0200, Denis Makogon wrote:

On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng
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.

Okay, my guess is that both osloconfig and oslolog are trying to
registerclioptions. I have to create a configuration object for
oslolog to work, and it means CLI options are registered once.
Later on, when I'm calling log.register
options(), it is conflicting
with previous registration.

So, I'm doubting whether these two packages have been tested together?

Regards,
Qiming

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


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

--
Davanum Srinivas :: https://twitter.com/dims

responded Jan 21, 2015 by Davanum_Srinivas (35,920 points)   2 4 9
0 votes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

Le 2015-01-21 11:16, Qiming Teng a ?crit?:

Any hint or sample code to setup logging if I'm abandoning the log
module from oslo.incubator?

You need to do:

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

Example of project that already use both:
https://github.com/stackforge/gnocchi/blob/master/gnocchi/service.py#L25

Cheers,


Mehdi Abaakouk
mail: sileht at sileht.net
irc: sileht

-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v.1.20131017
Comment: http://openpgpjs.org

wkYEAREIABAFAlS/qU4JEJZbdE7sD8foAAAQQwCfYN9jFNWp4OsxJts7Elmy
8taVKfYAn1uDtfn0aEJVDzXXbLdACzVxXEsB
=lHLc
-----END PGP SIGNATURE-----

responded Jan 21, 2015 by Mehdi_Abaakouk (4,040 points)   2 4
0 votes

On Wed, Jan 21, 2015 at 08:25:57AM -0500, Davanum Srinivas wrote:
Qiming,

Nova already uses oslo.config. there's a patch against nova to use
oslolog. Doug took the effort to do this so we'd not face issues once
we release oslo
log, so yes, they have been tested together. Please
hop onto #openstack-oslo to debug in real time.

[1] https://review.openstack.org/#/c/147635/

Thanks, glad to know some projects already took the adventure and it
works.

Regards,
Qiming

On Wed, Jan 21, 2015 at 8:11 AM, Qiming Teng wrote:

On Wed, Jan 21, 2015 at 12:27:15PM +0200, Denis Makogon wrote:

On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng
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.

Okay, my guess is that both osloconfig and oslolog are trying to
registerclioptions. I have to create a configuration object for
oslolog to work, and it means CLI options are registered once.
Later on, when I'm calling log.register
options(), it is conflicting
with previous registration.

So, I'm doubting whether these two packages have been tested together?

Regards,
Qiming

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.

responded Jan 21, 2015 by Qiming_Teng (7,380 points)   3 9 13
0 votes

It looks like this is already worked out, but there is some advice in the oslo.log docs [1] that might be useful.

Also, it?s important to note that oslo.log is not officially released as a stable API yet, so be careful with adoption. We cut a quiet release to make testing with applications easier, but may need to modify the API before making an official announcement that it?s ready to be used.

Doug

[1] http://docs.openstack.org/developer/oslo.log/usage.html#in-an-application

On Jan 21, 2015, at 9:38 AM, Qiming Teng wrote:

On Wed, Jan 21, 2015 at 08:25:57AM -0500, Davanum Srinivas wrote:

Qiming,

Nova already uses oslo.config. there's a patch against nova to use
oslolog. Doug took the effort to do this so we'd not face issues once
we release oslo
log, so yes, they have been tested together. Please
hop onto #openstack-oslo to debug in real time.

[1] https://review.openstack.org/#/c/147635/

Thanks, glad to know some projects already took the adventure and it
works.

Regards,
Qiming

On Wed, Jan 21, 2015 at 8:11 AM, Qiming Teng wrote:

On Wed, Jan 21, 2015 at 12:27:15PM +0200, Denis Makogon wrote:

On Wed, Jan 21, 2015 at 12:16 PM, Qiming Teng
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.

Okay, my guess is that both osloconfig and oslolog are trying to
registerclioptions. I have to create a configuration object for
oslolog to work, and it means CLI options are registered once.
Later on, when I'm calling log.register
options(), it is conflicting
with previous registration.

So, I'm doubting whether these two packages have been tested together?

Regards,
Qiming

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
responded Jan 21, 2015 by Doug_Hellmann (87,520 points)   3 4 12
0 votes

On Wed, Jan 21, 2015 at 08:25:57AM -0500, Davanum Srinivas wrote:
Qiming,

Nova already uses oslo.config. there's a patch against nova to use
oslolog. Doug took the effort to do this so we'd not face issues once
we release oslo
log, so yes, they have been tested together. Please
hop onto #openstack-oslo to debug in real time.

[1] https://review.openstack.org/#/c/147635/

Well, just checked nova code, it seems openstack.common.log is still
there. That means there are duplicated code such as the
'commoncliopts' which resides in both openstack.common.log and
oslolog.options.

I was getting the following error if I'm deleting openstack.common.log
module:

osloconfig.cfg.NoSuchOptError: no such option: logconfig_append

So ... even with oslo_log there, we still need openstack.common.log?
Pretty confused and a little frustrated after two days of digging.

Regards,
Qiming

responded Jan 21, 2015 by Qiming_Teng (7,380 points)   3 9 13
0 votes

Qiming,

Guessing you were looking at master. if you checkout the review i
pointed to, you will see what others on the thread have pointed you
to:
https://github.com/openstack/oslo.log/blob/master/doc/source/usage.rst

We are using registeroptions and setup. we should be adding
register
options in the future as need arises.

dims at dims-mac:~/openstack/nova$ find . -name "*.py" -exec grep -H
logging {} \; | grep -e ".setup" -e ".register_options" -e
".set_defaults"
./nova/cmd/all.py: logging.setup(CONF, "nova")
./nova/cmd/api.py: logging.setup(CONF, "nova")
./nova/cmd/api_ec2.py: logging.setup(CONF, "nova")
./nova/cmd/api_metadata.py: logging.setup(CONF, "nova")
./nova/cmd/api_os_compute.py: logging.setup(CONF, "nova")
./nova/cmd/cells.py: logging.setup(CONF, 'nova')
./nova/cmd/cert.py: logging.setup(CONF, "nova")
./nova/cmd/compute.py: logging.setup(CONF, 'nova')
./nova/cmd/conductor.py: logging.setup(CONF, "nova")
./nova/cmd/console.py: logging.setup(CONF, "nova")
./nova/cmd/consoleauth.py: logging.setup(CONF, "nova")
./nova/cmd/dhcpbridge.py: logging.setup(CONF, "nova")
./nova/cmd/manage.py: logging.setup(CONF, "nova")
./nova/cmd/network.py: logging.setup(CONF, "nova")
./nova/cmd/novncproxy.py: logging.setup(CONF, "nova")
./nova/cmd/novncproxy.py: logging.setup(CONF, "nova")
./nova/cmd/objectstore.py: logging.setup(config.CONF, "nova")
./nova/cmd/scheduler.py: logging.setup(CONF, "nova")
./nova/cmd/serialproxy.py: logging.setup(CONF, "nova")
./nova/cmd/spicehtml5proxy.py: logging.setup(CONF, "nova")
./nova/cmd/xvpvncproxy.py: logging.setup(config.CONF, "nova")
./nova/openstack/common/report/guru_meditation_report.py:
logging.setup(CONF, 'blah')
./nova/test.py:logging.register_options(CONF)
./nova/test.py:logging.setup(CONF, 'nova')

If you file a review with what you have, maybe we can help, again, pop
onto the #openstack-oslo channel to ask

-- dims

On Wed, Jan 21, 2015 at 10:25 AM, Qiming Teng
wrote:
On Wed, Jan 21, 2015 at 08:25:57AM -0500, Davanum Srinivas wrote:

Qiming,

Nova already uses oslo.config. there's a patch against nova to use
oslolog. Doug took the effort to do this so we'd not face issues once
we release oslo
log, so yes, they have been tested together. Please
hop onto #openstack-oslo to debug in real time.

[1] https://review.openstack.org/#/c/147635/

Well, just checked nova code, it seems openstack.common.log is still
there. That means there are duplicated code such as the
'commoncliopts' which resides in both openstack.common.log and
oslolog.options.

I was getting the following error if I'm deleting openstack.common.log
module:

osloconfig.cfg.NoSuchOptError: no such option: logconfig_append

So ... even with oslo_log there, we still need openstack.common.log?
Pretty confused and a little frustrated after two days of digging.

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

--
Davanum Srinivas :: https://twitter.com/dims

responded Jan 21, 2015 by Davanum_Srinivas (35,920 points)   2 4 9
0 votes

On Wed, Jan 21, 2015 at 10:55:37AM -0500, Davanum Srinivas wrote:
Qiming,

Guessing you were looking at master. if you checkout the review i
pointed to, you will see what others on the thread have pointed you
to:
https://github.com/openstack/oslo.log/blob/master/doc/source/usage.rst

We are using registeroptions and setup. we should be adding
register
options in the future as need arises.

In most files listed below, the 'logging' refers to
nova/openstack/common/log.py instead of oslo_log/log.py. No project can
throw away openstack/common/log.py at the moment, because it breaks
things in many ways.

dims at dims-mac:~/openstack/nova$ find . -name "*.py" -exec grep -H
logging {} \; | grep -e ".setup" -e ".register_options" -e
".set_defaults"
./nova/cmd/all.py: logging.setup(CONF, "nova")
./nova/cmd/api.py: logging.setup(CONF, "nova")
./nova/cmd/api_ec2.py: logging.setup(CONF, "nova")
./nova/cmd/api_metadata.py: logging.setup(CONF, "nova")
./nova/cmd/api_os_compute.py: logging.setup(CONF, "nova")
./nova/cmd/cells.py: logging.setup(CONF, 'nova')
./nova/cmd/cert.py: logging.setup(CONF, "nova")
./nova/cmd/compute.py: logging.setup(CONF, 'nova')
./nova/cmd/conductor.py: logging.setup(CONF, "nova")
./nova/cmd/console.py: logging.setup(CONF, "nova")
./nova/cmd/consoleauth.py: logging.setup(CONF, "nova")
./nova/cmd/dhcpbridge.py: logging.setup(CONF, "nova")
./nova/cmd/manage.py: logging.setup(CONF, "nova")
./nova/cmd/network.py: logging.setup(CONF, "nova")
./nova/cmd/novncproxy.py: logging.setup(CONF, "nova")
./nova/cmd/novncproxy.py: logging.setup(CONF, "nova")
./nova/cmd/objectstore.py: logging.setup(config.CONF, "nova")
./nova/cmd/scheduler.py: logging.setup(CONF, "nova")
./nova/cmd/serialproxy.py: logging.setup(CONF, "nova")
./nova/cmd/spicehtml5proxy.py: logging.setup(CONF, "nova")
./nova/cmd/xvpvncproxy.py: logging.setup(config.CONF, "nova")
./nova/openstack/common/report/guru_meditation_report.py:
logging.setup(CONF, 'blah')
./nova/test.py:logging.register_options(CONF)
./nova/test.py:logging.setup(CONF, 'nova')

If you file a review with what you have, maybe we can help, again, pop
onto the #openstack-oslo channel to ask

Okay, will do. Thanks.

Regards,
Qiming

-- dims

On Wed, Jan 21, 2015 at 10:25 AM, Qiming Teng
wrote:

On Wed, Jan 21, 2015 at 08:25:57AM -0500, Davanum Srinivas wrote:

Qiming,

Nova already uses oslo.config. there's a patch against nova to use
oslolog. Doug took the effort to do this so we'd not face issues once
we release oslo
log, so yes, they have been tested together. Please
hop onto #openstack-oslo to debug in real time.

[1] https://review.openstack.org/#/c/147635/

Well, just checked nova code, it seems openstack.common.log is still
there. That means there are duplicated code such as the
'commoncliopts' which resides in both openstack.common.log and
oslolog.options.

I was getting the following error if I'm deleting openstack.common.log
module:

osloconfig.cfg.NoSuchOptError: no such option: logconfig_append

So ... even with oslo_log there, we still need openstack.common.log?
Pretty confused and a little frustrated after two days of digging.

Regards,
Qiming

responded Jan 22, 2015 by Qiming_Teng (7,380 points)   3 9 13
...