Skip to main content

python logging done my way

Project description

stdlogpj

python logging done my way

home: https://github.com/prjemian/stdlogpj

INSTALL

pip install stdlogpj

USAGE:

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

DEMO:

#!/usr/bin/env python

import stdlogpj

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


def thing1(i):
    logger.info(f"something #{i+1}")


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


if __name__ == "__main__":
    logger.warning("before main()")
    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.2.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

stdlogpj-1.0.2-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file stdlogpj-1.0.2.tar.gz.

File metadata

  • Download URL: stdlogpj-1.0.2.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4

File hashes

Hashes for stdlogpj-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4cc9d6750928a912b7907406b5fef663ad81157a706a5f2747bfbfe17f5ea6fd
MD5 956b86315d905dc0efcdf110943f1b56
BLAKE2b-256 9b500b0785774b0e99c12a9c1ac4220a192c03f28b63775fab119e6d397e1fec

See more details on using hashes here.

File details

Details for the file stdlogpj-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: stdlogpj-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4

File hashes

Hashes for stdlogpj-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fc924026d61a4be1cf3bb629675799c557408e08447b4409230a9055deae4570
MD5 48304b0bbc697b6ff89897ab29351650
BLAKE2b-256 3577a555ecf17e415b8c1fa77e08a6672e54a40445815607d45513e45a56156c

See more details on using hashes here.

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