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

2013-12-09 Thread Paul Michali
Thanks! That worked



PCM (Paul Michali)

MAIL  p...@cisco.com
IRCpcm_  (irc.freenode.net)
TW@pmichali
GPG key4525ECC253E31A83
Fingerprint 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83

On Dec 9, 2013, at 5:27 PM, Vishvananda Ishaya  wrote:

> 
> On Dec 6, 2013, at 2:09 PM, Paul Michali  wrote:
> 
>> 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 believe you can just make sure to set_override on the CONF option to True 
> and then call logging.setup('neutron')
> 
> Here is an example with the nova code
> 
> >>> from nova.openstack.common import log as logging
> >>> LOG = logging.getLogger(__name__)
> >>> LOG.debug('foo')
> >>> logging.CONF.set_override('debug', True)
> >>> logging.setup('nova')
> >>> LOG.debug('foo')
> 2013-12-09 14:25:21.220 72011 DEBUG __main__ [-] foo  :2
> 
> Vish
> 
> 
>> 
>> 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  p...@cisco.com
>> IRCpcm_  (irc.freenode.net)
>> TW@pmichali
>> GPG key4525ECC253E31A83
>> Fingerprint 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83
>> 
>> ___
>> OpenStack-dev mailing list
>> OpenStack-dev@lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> 
> ___
> OpenStack-dev mailing list
> OpenStack-dev@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2013-12-09 Thread Vishvananda Ishaya

On Dec 6, 2013, at 2:09 PM, Paul Michali  wrote:

> 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 believe you can just make sure to set_override on the CONF option to True and 
then call logging.setup('neutron')

Here is an example with the nova code

>>> from nova.openstack.common import log as logging
>>> LOG = logging.getLogger(__name__)
>>> LOG.debug('foo')
>>> logging.CONF.set_override('debug', True)
>>> logging.setup('nova')
>>> LOG.debug('foo')
2013-12-09 14:25:21.220 72011 DEBUG __main__ [-] foo  :2

Vish


> 
> 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  p...@cisco.com
> IRCpcm_  (irc.freenode.net)
> TW@pmichali
> GPG key4525ECC253E31A83
> Fingerprint 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83
> 
> ___
> OpenStack-dev mailing list
> OpenStack-dev@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2013-12-06 Thread Paul Michali
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  p...@cisco.com
IRCpcm_  (irc.freenode.net)
TW@pmichali
GPG key4525ECC253E31A83
Fingerprint 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev