argparse-logging

raw JSON →
2020.11.26 verified Fri May 01 auth: no python maintenance

A simple library to configure logging from command line arguments when using argparse. Version 2020.11.26, last released in 2020 (no recent updates).

pip install argparse-logging
error ModuleNotFoundError: No module named 'argparse_logging'
cause Library not installed or incorrect import name.
fix
Install with pip install argparse-logging and import as 'from argparse_logging import ArgparseLogging'.
error AttributeError: module 'argparse_logging' has no attribute 'ArgparseLogging'
cause Wrong import due to naming inconsistency or version mismatch.
fix
Ensure you have the correct version installed and use: from argparse_logging import ArgparseLogging
gotcha The library hasn't been updated since 2020 and relies on older Python conventions. It may not work well with modern logging customizations.
fix Consider using argparse's own argparse.ArgumentDefaultsHelpFormatter or manual logging configuration for more control.
deprecated No official deprecation, but the library is effectively in maintenance mode with no active development. Breaking changes or compatibility issues with newer Python versions may arise.
fix Migrate to custom argparse + logging setup for future-proofing.

Basic usage to integrate logging with argparse.

import argparse
from argparse_logging import ArgparseLogging

parser = argparse.ArgumentParser()
ArgparseLogging(parser, log_level='info', log_format='%(asctime)s - %(levelname)s - %(message)s')
args = parser.parse_args()
# Now logging is configured from command line args (e.g., --log-level debug)
import logging
logging.getLogger().info('This is a test message')