1 |
On 08 Oct 2015 18:24, Brian Dolbec wrote: |
2 |
> On Thu, 8 Oct 2015 20:38:25 -0400 Mike Frysinger wrote: |
3 |
> > how do people feel about killing off the use of "print" everywhere and |
4 |
> > moving to the standard logging module ? biggest advantages in my |
5 |
> > mind: |
6 |
> > - we get much easier control over where the output goes |
7 |
> > (file/stdout/...) |
8 |
> > - we force people to select a level (info/warning/error) |
9 |
> > - we get standardized output |
10 |
> > - we can more easily control the output (debug/verbose/etc...) |
11 |
> > - we can include module/func/line info transparently in debug modes |
12 |
> > - we can exit transparently on fatal/critical messages (rather than |
13 |
> > using die/exit/etc... directly) |
14 |
> > - we can colorize warnings/errors transparently |
15 |
> > - we get py3 compat for free (all current print usage is py2-only) |
16 |
> |
17 |
> It's been on our wish list for several years. So go for it! |
18 |
|
19 |
done! |
20 |
|
21 |
> That'll be one less thing holding up p3 compatibility. |
22 |
> |
23 |
> I've added some extra print statements in there doing the re-write, but |
24 |
> there was just too much in there that needed fixing. |
25 |
|
26 |
i have noticed that DeComp calls print() and that's bad juju -- modules |
27 |
should never call print(). |
28 |
|
29 |
if you do want to expose details like that in a module, you should use |
30 |
the logging module and tie it to a specific logger. something like: |
31 |
logger = logging.getLogger('DeComp') |
32 |
logger.setLevel(logging.CRITICAL) |
33 |
and then DeComp would only ever call logger.xxx to log output. |
34 |
|
35 |
if people want to get logging details from DeComp, then they'd do: |
36 |
import DeComp |
37 |
DeComp.logger.setLevel(logging.DEBUG) |
38 |
assuming you put the logger into __init__.py of course. i have no opinion |
39 |
on how you want to structure that logic. |
40 |
-mike |