Pergunta

I'm logging some debug information on one of our Plone packages that needs to be rendered when the buildout logger level is set to DEBUG, but I found a little bit hard to use the information as there are some other modules (like Chameleon and transaction) that use this same level but are really verbose as you can see below:

2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: 7a9bea82827d89ebb6409b5b5b3c446f.py.
2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: 05974e2b844eb50bd08b35e69524ff1e.py.
2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: 05974e2b844eb50bd08b35e69524ff1e.py.
2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: fd6cd084759f934ad5b1873dcc864e89.py.
2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: fd6cd084759f934ad5b1873dcc864e89.py.
2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: 388b0bfda4923b35fa189b2f6f1e352e.py.
2014-01-17 16:56:38 DEBUG chameleon.loader loading module from cache: 388b0bfda4923b35fa189b2f6f1e352e.py.
2014-01-17 16:56:38 DEBUG txn.140171035764480 commit <Connection at 05b26150>
2014-01-17 16:56:38 DEBUG txn.140171035764480 commit
2014-01-17 16:56:38 DEBUG txn.140171035764480 new transaction
2014-01-17 16:56:38 DEBUG txn.140171035764480 abort
2014-01-17 16:56:38 DEBUG txn.140171035764480 new transaction
2014-01-17 16:56:38 DEBUG txn.140171027371776 new transaction
2014-01-17 16:56:38 DEBUG txn.140171035764480 commit
2014-01-17 16:56:38 DEBUG txn.140171035764480 new transaction
2014-01-17 16:56:38 DEBUG txn.140171035764480 abort

is there any way to provide these other modules with a different logger level?

I'm using the following configuration for the instance on my buildout.cfg:

[instance]
debug-mode = on
event-log-level = DEBUG
verbose-security = on
z2-log-level = DEBUG
Foi útil?

Solução 2

you can't change the log level of the other packages w/o patching them.

however, you could use the next higher level (i think it's logger.warn() in your package change the instance to this level.

alternatively you use grep on instance.log and grep only for your package's name there.

Outras dicas

You can't set a debug level for a specific module (product) in the buildout.

The buildout event-log-level is a global setting.

I'm not sure if this is the same as what fRiSi is advising, but this is how I solved the problem a few weeks back:

import logging

logger = logging.getLogger('my.product')

# Our logging will be shown with level at INFO & not with level at WARN
logger.setLevel(logging.WARN)

...

def update(self):

    logger.info("starting banner search at %s " % self.context )
    if IFolderish.providedBy(self.context):
        logger.info("findBannerImageFor(self) %s " % self.context )

This won't show any logging as is, but you can just change the relevant line to: logger.setLevel(logging.INFO) and you will see it all (& none of that transaction stuff)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top