Skip to content
/ arglog Public

Add root logger config to argparse automatically

License

Notifications You must be signed in to change notification settings

cjrh/arglog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://travis-ci.org/cjrh/arglog.svg?branch=master https://coveralls.io/repos/github/cjrh/arglog/badge.svg?branch=master

arglog

Add logging options to argparse automatically

Demo

# main.py
import argparse
import logging
import arglog

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    arglog.patch(parser)
    args = parser.parse_args()

This will trigger the same effect as running:

logging.basicConfig(level='<level name>')

However, you now also have a new CLI option for your program:

$ python main.py --loglevel=WARNING

All of the logging levels are supported, INFO, DEBUG and so on.

About

Add root logger config to argparse automatically

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages