Custom log with rotations
Project description
Log Functions
Install
pip install ddcLogs
BasicLog
- Setup Logging
from ddcLogs import BasicLog
logger = BasicLog(level="info").init()
logger.warning("This is a warning example")
SizeRotatingLog
- Setup Logging
- Logs will rotate based on the file size
- Logs will be deleted based on the
days_to_keep
variable, defaults to 30
from ddcLogs import SizeRotatingLog
logger = SizeRotatingLog(
level = "info",
directory = "logs",
filenames = ["app.log", "app1.log"],
days_to_keep = 7,
max_mbytes = 5,
name = "app_name",
stream_handler = True, # Add stream handler along with file handler
show_location = False # This will show the filename and the line number where the message originated
).init()
logger.warning("This is a warning example")
TimedRotatingLog
- Setup Logging
- Logs will rotate based on
when
variable to a.gz
file, defaults tomidnight
- Logs will be deleted based on the
days_to_keep
variable, defaults to 30 - Current 'when' events supported:
- midnight - roll over at midnight
- W{0-6} - roll over on a certain day; 0 - Monday
- Logs will rotate based on
from ddcLogs import TimedRotatingLog
logger = TimedRotatingLog(
level = "info",
directory = "logs",
filenames = ["app.log", "app1.log"],
days_to_keep = 7,
when = "midnight",
utc = True,
name = "app_name",
stream_handler = True, # Add stream handler along with file handler
show_location = False # This will show the filename and the line number where the message originated
).init()
logger.warning("This is a warning example")
Example of output
[2024-10-08T19:08:56.918]:[WARNING]:[app_name]:This is a warning example
Source Code
Build
poetry build -f wheel
Publish to test pypi
poetry publish -r test-pypi
Publish to pypi
poetry publish
Run Tests
poetry run coverage run -m pytest -v
Get Coverage Report
poetry run coverage report
License
Released under the MIT License
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
ddclogs-2.0.6.tar.gz
(6.2 kB
view details)
Built Distribution
File details
Details for the file ddclogs-2.0.6.tar.gz
.
File metadata
- Download URL: ddclogs-2.0.6.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9acc8b596323fef0254441c70324710ea04e340c879c642a34a81fec9514adb |
|
MD5 | c7b5cc876200f68b88daacd230abd292 |
|
BLAKE2b-256 | 61269d7877284d081c8ce43a478a8654433cb67d90a572a2be4c3b2b49a32b20 |
Provenance
The following attestation bundles were made for ddclogs-2.0.6.tar.gz
:
Publisher:
workflow.yml
on ddc/ddcLogs
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
ddclogs-2.0.6.tar.gz
- Subject digest:
c9acc8b596323fef0254441c70324710ea04e340c879c642a34a81fec9514adb
- Sigstore transparency entry: 150916045
- Sigstore integration time:
- Predicate type:
File details
Details for the file ddclogs-2.0.6-py3-none-any.whl
.
File metadata
- Download URL: ddclogs-2.0.6-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 307aeb346feb44d79d6b2998f3b0fdec18ccab511b75e25371e127eee0b54b41 |
|
MD5 | 790bc6e06f2aa7ef5f47c9e665ccc1ad |
|
BLAKE2b-256 | 153a996ee718a40ab99fa461d3c9d6ace222d6b6c5af84fb9e8cd5e01c5a7e72 |
Provenance
The following attestation bundles were made for ddclogs-2.0.6-py3-none-any.whl
:
Publisher:
workflow.yml
on ddc/ddcLogs
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
ddclogs-2.0.6-py3-none-any.whl
- Subject digest:
307aeb346feb44d79d6b2998f3b0fdec18ccab511b75e25371e127eee0b54b41
- Sigstore transparency entry: 150916046
- Sigstore integration time:
- Predicate type: