Python Log Library examples
This commit is contained in:
parent
8a04448f63
commit
1dca56be86
27
code/Python/loguru.py
Normal file
27
code/Python/loguru.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
|
||||||
|
def logger_export() -> None:
|
||||||
|
logger.add("file_1.log", rotation="500 MB") # Automatically rotate too big file
|
||||||
|
logger.add("file_2.log", rotation="12:00") # New file is created each day at noon
|
||||||
|
logger.add("file_3.log", rotation="1 week") # Once the file is too old, it's rotated
|
||||||
|
logger.add("file_X.log", retention="10 days") # Cleanup after some time
|
||||||
|
logger.add("file_Y.log", compression="zip") # Save some loved space
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="INFO")
|
||||||
|
|
||||||
|
logger.trace("trace")
|
||||||
|
logger.debug("debug")
|
||||||
|
logger.info("info")
|
||||||
|
logger.success("success")
|
||||||
|
logger.warning("warning")
|
||||||
|
logger.error("error")
|
||||||
|
logger.critical("critical")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user