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.3rc1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file stdlogpj-1.0.3rc1.tar.gz.

File metadata

  • Download URL: stdlogpj-1.0.3rc1.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for stdlogpj-1.0.3rc1.tar.gz
Algorithm Hash digest
SHA256 9c1ecc2c60e59395d12a8824850ae9641e8c5a769cc7980b1c7d104d677a04af
MD5 9a21d923bfd45c0594bb339b9afb7792
BLAKE2b-256 affce65fa19cf014a8fa385d0168db84592d45952686b8d9d978f345f483472b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stdlogpj-1.0.3rc1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for stdlogpj-1.0.3rc1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 802690071222c0f34c251a168eb2d858d5285fc392e02df14e6d3e5068d99502
MD5 177d6194ccbd3ae50015a7f204271049
BLAKE2b-256 840ab6b511211cf8332db45e8c7e02f536cb3c631a39269108649881fc81c6d4

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