Skip to main content

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

Project description

Argparse_logging

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

Without argparse_logging:

from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument(
    "--log-level", 
    default=logging.INFO, 
    type=lambda x: getattr(logging, x)),
    help="Configure the logging level.",
)
args = parser.parse_args()
logging.basicConfig(level=args.log_level)

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()
add_log_level_argument(parser)
args = parser.parse_args()

Project details


Download files

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

Source Distribution

argparse_logging-0.0.1.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argparse_logging-0.0.1-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file argparse_logging-0.0.1.tar.gz.

File metadata

  • Download URL: argparse_logging-0.0.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for argparse_logging-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0986f72bc9f45fd16203929020f13dce4cede9baa4ddbc13bc21a76750867e47
MD5 16aefda08cbffca012411f3c736917d3
BLAKE2b-256 189b8b6e49ff6a9832d3a93cca83c34fcc7d1d8b51c2c5c3171e984d50e42ccc

See more details on using hashes here.

File details

Details for the file argparse_logging-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: argparse_logging-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for argparse_logging-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6af7c5ca441977e38056a4bee16312bd2d53dd0292735795413fff22c0c18788
MD5 4188d46f32968ded24f630d731b85c07
BLAKE2b-256 01fd635d93fc6445ee8ea88825636bcacdd6e1fffb3e9605e47df9bf9a289ae4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page