Skip to main content

python logging done my way

Project description


python logging done my way



pip install stdlogpj


import stdlogpj
logger = stdlogpj.standard_logging_setup("demo")"hello")


#!/usr/bin/env python

import stdlogpj

logger = stdlogpj.standard_logging_setup("stdlogpj-demo")

def thing1(i):"something #{i+1}")

def main():"hello")
    for i in range(5):
        logger.debug("calling thing1()")

if __name__ == "__main__":
    logger.warning("before main()")
    logger.error("after main(): no error, really")

Rotate files and limit size

Using features of the RotatingFileHandler, it is possible to limit the size of the files by switching to a new log file, saving the old log file(s) by appending a number. Lower numbers are more recent.

Use this instead to limit logs to 1 MB and no more than 5 numbered (previous) log files:

logger = stdlogpj.standard_logging_setup("stdlogpj-demo", maxBytes=1024*1024, backupCount=5)

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

stdlogpj-1.0.3.tar.gz (24.2 kB view hashes)

Uploaded source

Built Distribution

stdlogpj-1.0.3-py2.py3-none-any.whl (9.2 kB view hashes)

Uploaded py2 py3

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