On 09 Oct 2015 08:26, Brian Dolbec wrote:
> On Fri, 9 Oct 2015 02:04:10 -0400 Mike Frysinger wrote:
> > i have noticed that DeComp calls print() and that's bad juju --
> > modules should never call print().
> >
> > if you do want to expose details like that in a module, you should use
> > the logging module and tie it to a specific logger. something like:
> > logger = logging.getLogger('DeComp')
> > logger.setLevel(logging.CRITICAL)
> > and then DeComp would only ever call logger.xxx to log output.
> >
> > if people want to get logging details from DeComp, then they'd do:
> > import DeComp
> > DeComp.logger.setLevel(logging.DEBUG)
> > assuming you put the logger into __init__.py of course. i have no
> > opinion on how you want to structure that logic.
>
> Yeah, I had every intention for it to use logging, I just needed
> catalyst to get to using it. So catalyst would provide a logger for
> it. I didn't have any intention for DeComp to create it's own. I's
> just a small module that will live in other apps.if you call any logging function, you're picking a logger. even if you just call logging.log(...), you're implicitly picking the root logger. the advantage of DeComp creating its own logger is that people don't have to filter out messages from it. so while we might want catalyst to run in verbose mode, i don't think we want modules it pulls in like DeComp also cluttering up the output. if we did actually want messages from DeComp, we can configure the logger it's using to have a higher level. -mike
signature.asc
Description: Digital signature
