Helpful classes, functions, & utilities for the stdlib `logging` module. No external dependencies.
Project description
red-log
Helpful classes, functions, & utilities for the stdlib logging
module. No external dependencies.
Project Links
Site | URL |
---|---|
🏠 Repository | Github: redjax/red-logging |
📚 Docs | ReadTheDocs |
🐍 Pypi | projects/red-logging |
Why?
I wanted to learn the stdlib logging
module, and found I liked configuring my logger(s) with logging.config.dictConfig()
. However, I did not want to have to continually check reference pages, copy/paste code, and do all the logging setup by hand each time.
red-log
does not import any 3rd party modules, only Python's stdlib modules are used. This package does not necessarily aim to simplify configuring logging, but the config classes help by exposing configuration options for the logging
module's formatters, handlers, and loggers.
Logger Configuration
With dictConfig()
Base config dict:
{
"version": 1,
"disable_existing_loggers": False,
"propagate": True,
"root": {},
"formatters": {},
"handlers": {},
"loggers": {}
}
from logging.config import dictConfig
logging_configdict: dict = {
"version": 1,
"disable_existing_loggers": false,
"propagate": true,
"root": {
"": {
"handlers": [
"console"
],
"level": "NOTSET"
}
},
"formatters": {
"default": {
"format": "[%(asctime)s] [%(levelname)s] > [%(filename)s:%(lineno)d] [%(funcName)s]: %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S"
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "default",
"level": "DEBUG",
"stream": "ext://sys.stdout"
}
},
"loggers": {
"": {
"handlers": [
"console"
],
"level": "NOTSET"
}
}
}
dictConfig(logging_configdict)
log = logging.getLogger(__name__)
log.info("Logger configured")
Links
- python-guide.org: Logging in a library
- docs.python.org: Configuring logging for a library
- RealPython: Logging in Python
- dev.to: Using the logger class in Python
- machinelearningplus.com: Python logging guide
- askpython.com: Configure logging in Python
- betterprogramming.pub: How to implement logging in your Python application
- Medium.com: Create a reusable logger factory
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
Built Distribution
File details
Details for the file red_logging-0.1.3.tar.gz
.
File metadata
- Download URL: red_logging-0.1.3.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.11.6 Linux/5.15.0-112-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0acc5bd6f33a7284cb8fc70ebd52d2cfd1bf2df87b39803c47da76b4c87d07c6 |
|
MD5 | 62161b2b554f1ad9275bd3f8ba1c281c |
|
BLAKE2b-256 | a3562dd294c5605bde1b87b28bef24b1cffb9d2b0372d3128950a526819650ef |
File details
Details for the file red_logging-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: red_logging-0.1.3-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.11.6 Linux/5.15.0-112-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f610c461732845f5ed377621a83739ed4213a95ff4886da11289ce918114fb3 |
|
MD5 | 97245101200bab7b4d0d316bca30d6dd |
|
BLAKE2b-256 | 10040a8e7e5a90a52d8d58e67cc871cf5d9e4c6d949e8ebf33deb643748fab10 |