PyLogg
Logging and YAML-based configuration modules in Python.
Installation
You can install this package from PyPI with pip.
pip install -U pylogg
Usage
Set up the logger in the main script.
import pylogg
pylogg.init(pylogg.Level.TRACE, colored=False)
pylogg.info("Hello world.")
Update individual settings if needed. These settings will override the settings set using pylogg.get() instances.
import pylogg as log
# Set output file
log.setFile(open("test.log", "w+"))
# Show date and times on console
log.setConsoleTimes(show=True)
# Save date and times to file
log.setFileTimes(show=True)
# Set global logging level
log.setLevel(log.DEBUG)
# Override the level of a named sub-logger
log.setLoggerLevel('module', log.INFO)
# Use
log.info("Hello world")
# Close the log file
log.close()
Use sub-logger from the modules.
import time
import pylogg
# Create or get a named sub-logger.
log = pylogg.get(__name__)
# Use
def run():
log.Trace("Running module ...")
# Support for f strings.
log.Debug("2 + 2 = {} ({answer})", 2 + 2, answer=True)
def timing():
# Get the timer instance
t1 = log.Info("Started process ...")
# long process
time.sleep(2)
# Call timer.done() to log elapsed time.
t1.done("Process completed.")
Note: Full logg package must be imported. Use import pylogg,
do not use from pylogg import get.
See the examples for more details.
Development
# Create a fork and clone the git repo.
git clone https://github.com/akhlakm/python-logg.git
cd python-logg
# Install dev requirements.
pip install -e .[dev]
# Install pre-commit git hooks.
pre-commit install
# Make changes and commit.
# Bump the version
./make.sh bump
# Publish new tag.
./make.sh publish
About
LICENSE MIT Copyright 2024 Akhlak Mahmood
Metadata
Release files for pylogg 0.4.1
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 | |
|---|---|---|---|---|
| pylogg-0.4.1.tar.gz | 15.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pylogg-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.3 kB
Release files / pylogg-0.4.1.tar.gz
| Download URL | pylogg-0.4.1.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
162daaebb5b9d5633eb0b8b7fe3d677dacc3da523f49f015ed05d2cd8206074f
|
|
BLAKE2b-256 checksum How to use checksums |
a4a6cae7cf4b3e2b57e8f986937b3b320de999af234049645febdb7979ad7459
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / pylogg-0.4.1-py3-none-any.whl
| Download URL | pylogg-0.4.1-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
380aa683120ab7488fa231d40472ba747bfcfe7d9fe8ef035681b3586b0a1b9d
|
|
BLAKE2b-256 checksum How to use checksums |
3e0d40e65ffb1e7c2ec6eb900ed7cfe4ab654fe5ca22d5d07c846126e8945f06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for pylogg 0.4.1
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.