Package: goatl
goatlInstallationpipinstall-Ugoatlor install withPoetrypoetryaddgoatlPurposegoatl provides a simple and easy to use logging interface for python projects.
by replacing repetitive boilerplate code with a simple function call:
the magic "log" function.fromgoatlimportloggoatl usage is all about the logUsageas a functionlog("hello world")# 2020-07-19 16:00:00,000 - goatl - INFO - hello worldlog.debug("hello world?")# 2020-07-19 16:00:00,000 - goatl - DEBUG - hello world?log.info("do you know the answer of{}+{}?",41,1)# 2020-07-19 16:00:00,000 - goatl - INFO - do you know the answer of 41 + 1?as a method decorator@logdeffoo(x,y):returnx+y@log.debugdefbar():return"hello world"@log.debug(return_level=log.info)defbaz(x):returnx*2foo(1,2)# ... INFO - foo called with args: (1, 2), kwargs: {}# ... DEBUG - foo returned: 3bar()# ... DEBUG - bar called with args: (), kwargs: {}# ... DEBUG - bar returned: hello worldbaz(3)# ... DEBUG - baz called with args: (3,), kwargs: {}# ... INFO - baz returned: 6as a class decorator@logclassFoo:def__init__(self,x):self.x=xdefbar(self,y):returnself.x+y@log.warndefbaz(self):returnself.x*2foo=Foo(1)# ... INFO - Instantiated Foo with args: (1,), kwargs: {}foo.bar(2)# ... INFO - Foo.bar called with args: (2,), kwargs: {}# ... DEBUG - Foo.bar returned: 3foo.baz()# ... WARNING - Foo.baz called with args: (), kwargs: {}# ... WARNING - Foo.baz returned: 2configurations shortcutsfile_formatter=log.Formatter("%(asctime)s-%(name)s-%(levelname)s-%(message)s")log.addFileHandler("foo.log",fmt=file_formatter)log.addStreamHandler(fmt="%(levelname)s-%(message)s")log.basicConfig(...)logging interface #not implemented yetI do plan to implement goatl's interaction with logging through an interface
such that it will be possible to use goatl with any logging backend.log.setBackend(logging)log.setBackend(loguru)logger=log.getLogger("foo")core conceptsIn order to justify the existence of goatl,
it must fulfill three important core concepts:Unobtrusive - it should not interfere* with the existing code.Ease of use - using it should be intuitive and pythonic.Clean - the amount of code added to the existing code should be minimal.* - logging will always carry a performative cost, goatl will aim at keeping it to a minimum.meansextensive testing of goatl must be implemented to ensure that it does not interfere with the existing code.
it should be tested by wrapping other popular libraries and modules with goatl.
this will ensure that goatl does not interfere with the existing code.
performance tests should be implemented to measure the performance cost of goatl,
it should not exceed a reasonable threshold, in comparison to adding logging manually.main featuresthe log function provides an easy interace for:out of and in context log callswrapping existing functions with log callswrapping existing classes with log callswrapping existing modules with log calls #not implemented yet, is this even possible?logging configuration #not implemented yetsupport multiple logging backends #not implemented yetall in an intuitive and pythonic way.ReleasesYou can see the list of available releases on theGitHub Releasespage.LicenseThis project is licensed under the terms of theMITlicense. SeeLICENSEfor more details.Citation@misc{goatl,author={goatl},title={goat logger},year={2023},publisher={GitHub},journal={GitHub repository},howpublished={\url{https://github.com/EytanDn/goatl}}}