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.2.tar.gz
(23.6 kB
view hashes)
Built Distribution
Close
Hashes for stdlogpj-1.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc924026d61a4be1cf3bb629675799c557408e08447b4409230a9055deae4570 |
|
MD5 | 48304b0bbc697b6ff89897ab29351650 |
|
BLAKE2b-256 | 3577a555ecf17e415b8c1fa77e08a6672e54a40445815607d45513e45a56156c |