[openstack-dev] [neutron] Questions on logging setup for development

Paul Michali pcm at cisco.com
Fri Dec 6 22:09:54 UTC 2013


Hi,

For Neutron, I'm creating a module (one of several eventually) as part of a new blueprint I'm working on, and the associated unit test module. I'm in really early development, and just running this UT module as a standalone script (rather than through tox). It allows me to do TDD pretty quickly on the code I'm developing (that's the approach I'm taking right now - fingers crossed :).

In the module, I did an import of the logging package and when I run UTs I can see messaging that would occur, if desired.

I have the following hack to turn off/on the logging for debug level:

if False:  # Debugging
    logging.basicConfig(format='%(asctime)-15s [%(levelname)s] %(message)s',
                        level=logging.DEBUG)

I made the log calls the same as what would be in other Neutron code, so that I don't have to change the code later, as I start to fold it into the Neutron code. However, I'd like to import the neutron.openstack.common.log package in my code, so that the code will be identical to what is needed once I start running this code as part of a process, but I had some questions…

When using neutron.openstack.common.log, how do I toggle the debug level logging on, if I run this standalone, as I'm doing now?
Is there a way to do it, without adding in the above conditional logic to the production code? Maybe put something in the UT module?

I can always continue as is, and then switch things over later (changing the import line and pulling the if clause), once I have things mostly done, and want to run as part of Neutron, but it would be nice if I can find a way to do that up front to avoid changes later.

Thoughts? Suggestions?

Thanks!


PCM (Paul Michali)

MAIL          pcm at cisco.com
IRC            pcm_  (irc.freenode.net)
TW            @pmichali
GPG key    4525ECC253E31A83
Fingerprint 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20131206/62a427b4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20131206/62a427b4/attachment-0001.pgp>


More information about the OpenStack-dev mailing list