New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic logging framework to handle args.quiet properly #1200
Conversation
retest this, please |
Please make the functions module level, and named So, you would do:
In particular, no objects need to be instantiated, passed around, or otherwise harmed in this utopian vision of a stupidly lightweight logging interface. |
So, how would I dynamically set verbosity? Would I just have a variable in the module that's "quiet" and I set it when we fire up a script? |
On Mon, Jul 27, 2015 at 01:39:17PM -0700, Jake Fenton wrote:
You have my permission to add a |
On Mon, Jul 27, 2015 at 11:40:53AM -0700, Jake Fenton wrote:
'warn' gets printed out with '-q', I'd say. |
I ended up changing what goes where; this is current: quiet == shushed on -q
|
|
@ctb Shall I proceed with adding more scripts in, or get this merged? |
get this reviewed :)
|
And on that note, @ctb @luizirber @mr-c CR, please? |
2015-07-27 Jacob Fenton <bocajnotnef@gmail.com> | ||
|
||
* scrips/normalize-by-median.py,khmer/khmer_logger.py: added logging | ||
framework, prorotyped in normalize-by-median |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prototyped
@bocajnotnef I'm sure you're cognisant of this, but please make sure that whenever stdout is used to output data, logging to stdout is automagically suppressed or redirected to stderr. |
@ctb pointed out that it was a bad idea to have any logging related stuff On Mon, Jul 27, 2015, 17:40 Kevin Murray notifications@github.com wrote:
|
Hmm. Why not just use Python's built in logging module? It's very simple https://docs.python.org/2/howto/logging.html#logging-basic-tutorial
|
Vetoed by @ctb--the quote used the phrase "festering pile of", as I recall. On Mon, Jul 27, 2015 at 10:14 PM Camille Scott notifications@github.com
|
@camillescott et al., please feel free to discuss logging frameworks here: #1024 . This PR is intended to fix #790 without necessarily adding a big chunk of code or a new library dependency. |
@bocajnotnef looks ok to me on a first pass. Main thought - do you want to make use of the implicit formatting of the log functions (e.g. line 88 in normalize-by-median), or keep the current mix? |
retest this please |
Does |
log_info('... kept {kept} of {tot} or {perc_kept:.1%} so' | ||
'far', kept=kept, tot=total, | ||
perc_kept=perc_kept) | ||
log_info('... in file ' + ifilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you switch this over to {} too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(lots of elsewhere)
Note: per conversation with @mr-c, I am happy to try to merge this for 2.0, but we will explore adding -q to more scripts/adding logging framework stuff/etc later, after we have some experience with +/- of this particular approach. |
@bocajnotnef note: #1179 (comment) - I fixed this in 24c5397, please use that language in future. |
@ctb WIlco re: language +'s removed, implicit format in use; Merge? |
Conflicts: ChangeLog
I repeat: #1200 (comment) |
@ctb Sorry, missed that--fixed now. Merge? |
Threw in some fixes; @mr-c @luizirber could you review, please? The logging functionality is fine, be good to get a double-check on the tst utils change. Also, @bocajnotnef, no more adding global khmer arguments if they're not being implemented throughout the codebase - this is strike 2 (see #1179 for strike 1). I removed args.quiet because it was only used in normalize-by-median.py! |
My understanding was that we were prototyping the use of --unique-kmers pre I had a similar understanding here--while Normalize-by-median is the Additionally, the --quiet arg was in place in the hashbits args prior to my That said, I should have pulled it down to just normalize's parser in this On Sat, Aug 1, 2015, 08:17 C. Titus Brown notifications@github.com wrote:
|
On Sat, Aug 01, 2015 at 09:00:24AM -0700, Jake Fenton wrote:
Yep, that's the plan, but (for both this and the --unique-kmers problem)
Huh, ok, apologies :)
Yep. Doesn't seem like I broke any tests so shrug. |
Yeah. Herein I'll make sure to contain things a bit more. Makes sense not On Sat, Aug 1, 2015, 09:04 C. Titus Brown notifications@github.com wrote:
|
Conflicts: ChangeLog scripts/normalize-by-median.py
Hah, I reverted the changes I made that needed review, so I think I'll merge (#1200 (comment)). |
Added basic logging framework to handle args.quiet properly
Thanks! |
print(message, file=sys.stderr) | ||
|
||
|
||
def log_debug(message, **kwagrs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kwargs
Please write a test that exercises this method and check for test coverage. Also, please review the pylint report for this file, your global
usage is off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Please see #1024 for discussions of logging frameworks.)
Four levels: info, warn, err, debug
Open to suggestions on what does what.
Ref #790 and #1024