Skip to content
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

Use of logging in example code #53

Open
ashander opened this issue Nov 2, 2017 · 1 comment
Open

Use of logging in example code #53

ashander opened this issue Nov 2, 2017 · 1 comment

Comments

@ashander
Copy link
Owner

ashander commented Nov 2, 2017

as pointed out in #52 using standard modules makes things easier on users. (but perhaps harder on us?)

@hyanwong
Copy link

hyanwong commented Nov 2, 2017

Jerome uses import logging in his code, and I think it makes things easier to read / program too. He uses:

log_level = logging.WARNING
if args.verbosity == 1:
    log_level = logging.INFO
if args.verbosity >= 2:
    log_level = logging.DEBUG
logging.basicConfig(
    format='%(asctime)s %(message)s', level=log_level, stream=sys.stdout)

(I guess you could use stream=args.logfile with

parser.add_argument("-g","--logfile", dest="logfile", type=argparse.FileType('r'), default='-', help="name of log file (or '-' for stdout)")

then

logging.debug("Some internal stuff")
logging.info("Message")
logging.warning("Something's wrong")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants