Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.38 KB

README.rst

File metadata and controls

52 lines (33 loc) · 1.38 KB
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.