Skip to main content

Custom log with rotations

Project description

Few Utility Functions

License Python PyPi Build Status

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",
    name = "app"
)
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,
    name = "app"
)
log.init()

TimedRotatingLog

  • Setup Logging
    • Logs will rotate based on when variable to a .tar.gz file, defaults to midnight
    • 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
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,
    name = "app"
)
log.init()

Source Code

Build

poetry build

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


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.9.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

ddclogs-1.0.9-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page