Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

This is a simple library to configure logging from command line argument when using argparse.

Project description


This is a simple library to configure logging from command line argument when using argparse.

Without argparse_logging:

from argparse import ArgumentParser

parser = ArgumentParser()
    type=lambda x: getattr(logging, x)),
    help="Configure the logging level.",
args = parser.parse_args()

This is a bit annoying to copy paste in every program.

Instead you can use argparse_logging to get the following:

from argparse import ArgumentParser
from argparse_logging import add_log_level_argument

parser = ArgumentParser()
args = parser.parse_args()


You will need git, pipenv, python, pre-commit. Then you can set up your virtual environment:

$ git clone
$ cd argparse_logging
$ pipenv update

Do whatever changes you want. You can run the tests and linting with:

$ pipenv run py.test
$ pre-commit

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for argparse-logging, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size argparse_logging-0.3-py3-none-any.whl (2.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size argparse_logging-0.3.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page