Overview
Installation
With Pip:
pip install simple_logging_config
Usage
The simple_logging_config package provides a simplified logging configuration.
To use with the default configuration, only 2 lines of code are required.
from simple_logging_config import configure_logging
configure_logging()
Or
from simple_logging_config import SimpleLoggingConfig
SimpleLoggingConfig()
This will enable info level logging to the console and debug level logging to a file.
Information logged to the console is just the log message with no additional detail.
Information logged to file includes the timestamp, log_level, module and message
For a slightly more complex usecase, using a few additional lines of code, configure_logging is configurable using command line parameters.
# myscript.py
from argparse import ArgumentParser
from simple_logging_config import configure_logging, add_logging_arguments
parser = ArgumentParser(description="Test Program")
add_logging_arguments(parser)
args = parser.parse_args()
configure_logging(**vars(args))
Your script will now accept additional CLI paramaters to configure logging at runtime as shown below.
usage: myscript.py [-h] [-v | --slc-level LEVELS] [--slc-modules [MODULES ...]] [--slc-log-file-path LOG_FILE_PATH]
[--slc-backup-count BACKUP_COUNT] [--slc-config {dual,dual_rotating,dual_detailed,console,file,rotating_file}]
Test Program
options:
-h, --help show this help message and exit
-v, --verbose The level of logging verbosity for the default handler. Use multiple times (up to -vvv) for increased
verbosity.
--slc-level LEVELS, --slc-levels LEVELS
The log level(s) to be applied to attached handlers. This value can be a single integer or a string
representing a defined log level. Or it can be a string representing a dictionary where key/value pairs
are handler names and the log level to be associated with that handler
--slc-modules [MODULES ...]
The names of the modules to be logged. If omitted all modules are logged.
--slc-log-file-path LOG_FILE_PATH
The path the log file will be saved to. If this is a folder, the log file will be saved to this folder
with the file name derived from the name of the calling script. Otherwise, assume this is a full path to
a named log file.
--slc-backup-count BACKUP_COUNT
An integer specifying The number of backup log files to retain.
--slc-config {dual,dual_rotating,dual_detailed,console,file,rotating_file}
The name of the logging config to be used.
Metadata
Release files for simple-logging-config 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_logging_config-0.0.2.tar.gz | 13.9 kB | Without provenance | Details for simple_logging_config-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_logging_config-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for simple_logging_config-0.0.2-py3-none-any.whl |
Total release size: 28.6 kB
Release files / simple_logging_config-0.0.2.tar.gz
| Download URL | simple_logging_config-0.0.2.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85e2ac5dc9169b48d1ee8cd5b017aea5349d5eae9a7526d83e3c172370740310
|
|
BLAKE2b-256 checksum How to use checksums |
8fa07eb5b4faed995faca086741dcb6171c55f02ced4bd0b822368b99d262bab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / simple_logging_config-0.0.2-py3-none-any.whl
| Download URL | simple_logging_config-0.0.2-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c51bf20d24993298c68f4dc6ee5edce0642cd74b0297f23901f98141ebe3ec4c
|
|
BLAKE2b-256 checksum How to use checksums |
a56020985df3a35838f84a99f9c2d595f166e82f73735eca910a0edfc71eaf1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for simple-logging-config 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.