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 hashes)
Built Distribution
Close
Hashes for stdlogpj-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed694b7edf25a4623f12889c0c885e2f222eb0db543e38c9e718e84605e5dd8c |
|
MD5 | 2341c4c4eacdb8e3d4d4071cb3046db3 |
|
BLAKE2b-256 | 7321055672d51de1d3cce48b5d003ce180cd66429e8b822016721d31f600de5e |