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
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
stdlogpj-1.0.3.tar.gz
(24.2 kB
view details)
Built Distribution
File details
Details for the file stdlogpj-1.0.3.tar.gz
.
File metadata
- Download URL: stdlogpj-1.0.3.tar.gz
- Upload date:
- Size: 24.2 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 184e30c0710395019e6396732ae17acdf3eb2bd6aa4c1e9fb662b818b219ba19 |
|
MD5 | b7a36eb957613c2f02320706061b87d9 |
|
BLAKE2b-256 | 06ff52dcab6dc56a85a247c1d689366c6c612d27afcda44edbfdf60cad01823e |
File details
Details for the file stdlogpj-1.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: stdlogpj-1.0.3-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed694b7edf25a4623f12889c0c885e2f222eb0db543e38c9e718e84605e5dd8c |
|
MD5 | 2341c4c4eacdb8e3d4d4071cb3046db3 |
|
BLAKE2b-256 | 7321055672d51de1d3cce48b5d003ce180cd66429e8b822016721d31f600de5e |