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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for argparse_logging-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6af7c5ca441977e38056a4bee16312bd2d53dd0292735795413fff22c0c18788 |
|
MD5 | 4188d46f32968ded24f630d731b85c07 |
|
BLAKE2b-256 | 01fd635d93fc6445ee8ea88825636bcacdd6e1fffb3e9605e47df9bf9a289ae4 |