Custom log with rotations
Project description
Few Utility Functions
Install
pip install ddcLogs
BasicLog
- Setup Logging
from ddcLogs import BasicLog
log = BasicLog(
level = "info",
datefmt = "%Y-%m-%dT%H:%M:%S",
encoding = "UTF-8",
)
log.init()
SizeRotatingLog
- Setup Logging
- Logs will rotate based on the file size
from ddcLogs import SizeRotatingLog
log = SizeRotatingLog(
level = "info",
directory = "logs",
filename = "app.log",
encoding = "UTF-8",
datefmt = "%Y-%m-%dT%H:%M:%S",
days_to_keep = 7,
max_mbytes = 5
)
log.init()
TimedRotatingLog
- Setup Logging
- Logs will rotate based on
when
variable to a.tar.gz
file, defaults tomidnight
- Logs will be deleted based on the
days_to_keep
variable, defaults to 7 - Current 'when' events supported:
- S - Seconds
- M - Minutes
- H - Hours
- D - Days
- 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
log = TimedRotatingLog(
level = "info",
directory = "logs",
filename = "app.log",
encoding = "UTF-8",
datefmt = "%Y-%m-%dT%H:%M:%S",
days_to_keep = 7,
when = "midnight",
utc = True
)
log.init()
Source Code
Build
poetry build
Run Tests
poe test
Get Coverage Report
poe coverage
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-1.0.7.tar.gz
(5.8 kB
view hashes)