Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] standardizing output
Date: Fri, 09 Oct 2015 15:27:25
Message-Id: 20151009082631.4f841bf9.dolsen@gentoo.org
In Reply to: Re: [gentoo-catalyst] standardizing output by Mike Frysinger
1 On Fri, 9 Oct 2015 02:04:10 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > On 08 Oct 2015 18:24, Brian Dolbec wrote:
5 > > On Thu, 8 Oct 2015 20:38:25 -0400 Mike Frysinger wrote:
6 > > > how do people feel about killing off the use of "print"
7 > > > everywhere and moving to the standard logging module ? biggest
8 > > > advantages in my mind:
9 > > > - we get much easier control over where the output goes
10 > > > (file/stdout/...)
11 > > > - we force people to select a level (info/warning/error)
12 > > > - we get standardized output
13 > > > - we can more easily control the output (debug/verbose/etc...)
14 > > > - we can include module/func/line info transparently in debug
15 > > > modes
16 > > > - we can exit transparently on fatal/critical messages (rather
17 > > > than using die/exit/etc... directly)
18 > > > - we can colorize warnings/errors transparently
19 > > > - we get py3 compat for free (all current print usage is py2-only)
20 > >
21 > > It's been on our wish list for several years. So go for it!
22 >
23 > done!
24 >
25 > > That'll be one less thing holding up p3 compatibility.
26 > >
27 > > I've added some extra print statements in there doing the re-write,
28 > > but there was just too much in there that needed fixing.
29 >
30 > i have noticed that DeComp calls print() and that's bad juju --
31 > modules should never call print().
32 >
33 > if you do want to expose details like that in a module, you should use
34 > the logging module and tie it to a specific logger. something like:
35 > logger = logging.getLogger('DeComp')
36 > logger.setLevel(logging.CRITICAL)
37 > and then DeComp would only ever call logger.xxx to log output.
38 >
39 > if people want to get logging details from DeComp, then they'd do:
40 > import DeComp
41 > DeComp.logger.setLevel(logging.DEBUG)
42 > assuming you put the logger into __init__.py of course. i have no
43 > opinion on how you want to structure that logic.
44 > -mike
45
46 Yeah, I had every intention for it to use logging, I just needed
47 catalyst to get to using it. So catalyst would provide a logger for
48 it. I didn't have any intention for DeComp to create it's own. I's
49 just a small module that will live in other apps.
50
51 I've just made the API consumer apps provide a logging or similar
52 suitable module.
53
54 I'll convert it over tomorrow.
55
56 I'm pleased it won't have it's first release using the print().
57 They were really just for debugging mostly. There are a few for errors.
58
59 I'll have a look at the other patches in the morning.
60
61
62 --
63 Brian Dolbec <dolsen>

Replies

Subject Author
Re: [gentoo-catalyst] standardizing output Mike Frysinger <vapier@g.o>