PKqJF0 0 iologger/__init__.py""" Decorator which logs the wrapped function/method. The following are logged: 1. name of the function called 2. arg(s) passed for the function called (if any) 3. kwarg(s) passed for the function called (if any) 4. execution time of the function called (in seconds) * also catches and logs any exceptions raised gracefully. """ import time import json from functools import partial, wraps from collections import OrderedDict from logbook import Logger __version__ = "1.1.6" class FunctionExecutionError(BaseException): pass def iologger(function=None, catch_exceptions=True): """ Decorator which logs the wrapped function/method. The following are logged: 1. name of the function called 2. arg(s) passed for the function called (if any) 3. kwarg(s) passed for the function called (if any) 4. execution time of the function called (in seconds) * also catches and logs any exceptions raised gracefully. :param catch_exceptions: will catch exceptions gracefully if true. :param function: func to run and all its args/kwargs. :return: returns func(*args, **kwargs) """ if function is None: return partial(iologger, catch_exceptions=catch_exceptions) logger = Logger() @wraps(function) def wrapper(*args, **kwargs) -> None: def run_function(func): arg_dict = OrderedDict() arg_dict['args'] = args arg_dict['kwargs'] = kwargs result = None start = time.time() try: result = func(*args, **kwargs) arg_dict['returned'] = str(result) except Exception as e: result = "Exception: {}".format(e) arg_dict['returned'] = str(result) arg_dict['exception'] = str(e) if not catch_exceptions: raise FunctionExecutionError finally: end = time.time() arg_dict['exec_time'] = "{:f} seconds".format(end - start) logger.info(json.dumps(arg_dict)) return result if catch_exceptions: with logger.catch_exceptions(): return run_function(function) else: return run_function(function) return wrapper PKyqJE5NNiologger/module_test.pyfrom io import StringIO import pytest from hypothesis import given from hypothesis.strategies import integers, permutations, text from logbook import StreamHandler from iologger import * @iologger def logged_function(a_string: str, an_int: int) -> str: """ Returns a str made from static text, a passed str, and a passed int. :param a_string: a str to be used in the returned string :param an_int: an int to be used in the returned string :return: a str which includes both a_string and an_int values """ return "Your str was '{}' and your int was '{}'.".format(a_string, an_int) @iologger def logged_exception_graceful() -> None: """ This function just raises an exception. :return: None """ raise PermissionError @iologger(catch_exceptions=False) def logged_exception_ungraceful() -> None: """ This function just raises an exception. :return: None """ raise PermissionError @pytest.fixture() def setup_logging(): logger = Logger('test_logger') return logger @given(t_str=text(alphabet='azbef'), t_int=integers()) def test_iologger_runs(t_str, t_int): assert logged_function(a_string=t_str, an_int=t_int) @given(t_str=permutations('azbef'), t_int=integers()) @pytest.mark.usefixtures('setup_logging') def test_args_logging(t_str, t_int): with StringIO() as logfile: stdout_handler = StreamHandler(logfile) stdout_handler.push_application() t_str = ''.join(t_str) logged_function(a_string=t_str, an_int=t_int) assert t_str in logfile.getvalue() assert str(t_int) in logfile.getvalue() stdout_handler.pop_application() @given(t_str=text(alphabet='azbef'), t_int=integers()) @pytest.mark.usefixtures('setup_logging') def test_iologger_debug_level(t_str, t_int): with StringIO() as logfile: stdout_handler = StreamHandler(logfile) stdout_handler.push_application() t_str = ''.join(t_str) logged_function(a_string=t_str, an_int=t_int) # assert "Starting" in logfile.getvalue() # assert "args/kwargs" in logfile.getvalue() # assert "Finished" in logfile.getvalue() assert logfile.getvalue() assert len(logfile.getvalue().splitlines()) == 1 stdout_handler.pop_application() @given(t_str=text(alphabet='azbef'), t_int=integers()) @pytest.mark.usefixtures('setup_logging') def test_iologger_info_level(t_str, t_int): with StringIO() as logfile: stdout_handler = StreamHandler(logfile, level="INFO") stdout_handler.push_application() t_str = ''.join(t_str) logged_function(a_string=t_str, an_int=t_int) # assert "Starting" not in logfile.getvalue() # assert "args/kwargs" in logfile.getvalue() # assert "Finished" not in logfile.getvalue() assert logfile.getvalue() assert len(logfile.getvalue().splitlines()) == 1 stdout_handler.pop_application() @given(t_str=text(alphabet='azbef'), t_int=integers()) @pytest.mark.usefixtures('setup_logging') def test_iologger_notice_level(t_str, t_int): with StringIO() as logfile: stdout_handler = StreamHandler(logfile, level="NOTICE") stdout_handler.push_application() t_str = ''.join(t_str) logged_function(a_string=t_str, an_int=t_int) # assert "Starting" not in logfile.getvalue() # assert "args/kwargs" not in logfile.getvalue() # assert "Finished" not in logfile.getvalue() assert logfile.getvalue() == "" stdout_handler.pop_application() @given(t_str=text(alphabet='azbef'), t_int=integers()) @pytest.mark.usefixtures('setup_logging') def test_iologger_notice_level(t_str, t_int): with StringIO() as logfile: stdout_handler = StreamHandler(logfile, level="NOTICE") stdout_handler.push_application() t_str = ''.join(t_str) logged_function(a_string=t_str, an_int=t_int) # assert "Starting" not in logfile.getvalue() # assert "args/kwargs" not in logfile.getvalue() # assert "Finished" not in logfile.getvalue() # assert logfile.getvalue() == "" stdout_handler.pop_application() # @pytest.mark.usefixtures('setup_logging') # def test_iologger_exception_catching_graceful(): # logged_exception_graceful() # # # @pytest.mark.usefixtures('setup_logging') # def test_iologger_exception_catching_ungraceful(): # with pytest.raises(FunctionExecutionError): # logged_exception_ungraceful() @pytest.mark.usefixtures('setup_logging') def test_iologger_exception_catching_logging(): with StringIO() as logfile: stdout_handler = StreamHandler(logfile) stdout_handler.push_application() logged_exception_graceful() # assert "Starting" in logfile.getvalue() # assert "args/kwargs" in logfile.getvalue() # assert "PermissionError" in logfile.getvalue() stdout_handler.pop_application() @given(t_str=text(alphabet='azbef'), t_int=integers()) @pytest.mark.usefixtures('setup_logging') def test_iologger_exception_catching_graceful_logging(t_str, t_int): with StringIO() as logfile: stdout_handler = StreamHandler(logfile) stdout_handler.push_application() logged_exception_graceful() t_str = ''.join(t_str) logged_function(a_string=t_str, an_int=t_int) # assert "Starting" in logfile.getvalue() # assert "args/kwargs" in logfile.getvalue() # assert "PermissionError" in logfile.getvalue() # assert "Finished" in logfile.getvalue() stdout_handler.pop_application() if __name__ == "__main__": pytest.main(['-v']) PKkt;JC"iologger/.cache/v/cache/lastfailed{}PKXf;J:|z!!?iologger/.hypothesis/examples/d11ab8b6baef3077/01ec548baccbe696PKPf;J/!!?iologger/.hypothesis/examples/d11ab8b6baef3077/20070074de316402ŀPKPf;Jk<7\!!?iologger/.hypothesis/examples/d11ab8b6baef3077/31bf9e18d6132942PKPf;JYQ !!?iologger/.hypothesis/examples/d11ab8b6baef3077/363af9b65c099c60PKPf;J!!?iologger/.hypothesis/examples/d11ab8b6baef3077/3b3bd7f3f5fe614bPKPf;J/f!!?iologger/.hypothesis/examples/d11ab8b6baef3077/55fb667caede5e32PKPf;J!!?iologger/.hypothesis/examples/d11ab8b6baef3077/5d5a3d8c9ff6583cPKPf;J+''?iologger/.hypothesis/examples/d11ab8b6baef3077/5fa4fa5f4dbe5909ŀPKPf;J%!!?iologger/.hypothesis/examples/d11ab8b6baef3077/6f70561bd02b37f0PKPf;J`!!?iologger/.hypothesis/examples/d11ab8b6baef3077/748ea665e48eca7cPKPf;JϺr0!!?iologger/.hypothesis/examples/d11ab8b6baef3077/799e1b536e553f23PKPf;JKeL!!?iologger/.hypothesis/examples/d11ab8b6baef3077/8e05ec1399bc61edPKPf;J|a<a<8iologger/.hypothesis/unicodedata/8.0.0/charmap.pickle.gztmp9rckc40mM |T̜ df3$ "*#}ֿk]R++L*U.mV[w%k}0g<=yt:X?-}U|#b쥋 K.],]pۥ-Ve*eKPY%uCvPsVSnNr^Ύ"|<(_m|Y+X|?\SXW.9rx37#8ތ26=#82CPQ;\383qgFp3G"##8H؛ ^o$Z]kkjuZ+{ umPg:+O c|֐{ a6<`P4LP/l.y0qEÄavrP>:L a>\(G v(yp[H^7ܖ_ /V&oaKFpaeA(l,cM#`s<m `enP6,yH[He#Lf2hc)6ܵv#Oj鍶C-#i5&d[5_dW6"&[BdȕMV&n|~-$?krԢb{-|֐_[V5h`Qֲ̬AY<8+`+^{, Ϧ1l6ypB>g_Y_9߆uVO6[l~rS[ٲu:{fɓ6MMV& ذk!ẉހ:6 7K7ɧ6rpɦA2P;(' |A*D|oߌq+~cq_ ^v:!x~&&/o?' +އG'Ɋ/8D>mH/W Zj}|Sw_ݗ??uR-+> >_~?Zy0%|v}$>}"d|lK?p/?TL_uq_p߅t=VkZnyp;׸op߄ݷl3kr/&/t oor× /9+^׺ގǹO'O't >}_|Cݏv?~:p?k-+~b}Q+ݟM 򖆊%#},)f :MuQ5Dz }6|؊V=fz8s\sݏOt_q^vy<>Y=ߝ_//x|9Pŏguh/t_~~-xyZN4W3{BO(})~[Kxmm??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\ OzJu0ywOFy{GN#Xbْ ɓ͒Y<`h4{c}!ci%軑P Y!^z].FZ-FC<Zk~Rqr/h}EXw`p]ߗ7:/DdF)tpz$i҇3d'pTJWlHOܔs]BeDvzU.Ԯ eRM_{ 3xNKJi?8a(\T C("YT PK!H?2 iologger-1.1.6.dist-info/RECORDΪH}?U@Ԣ8ϢR O&wӝ IwrEArM m_Q2v:y-}x[ۮX9^,hւgfGQGv,Jo"ѢB8`ϱFYܚbEIm;HW%?G@H02T(9 F9gFC9m}߳֯j͝վ=SD9b˴WU_& %Oj6maѴ/# pփe wŃ/THh UhUУ4WZwSNJ}*$%MHy~}ba!Vwoo88]^MR-y4aT&P Q(1[2˯#Sme͢Ds/nӮ*iλ/TBΩIqxˏם?[/ M8GX8VL9B$ 12TVGde6i-/M w4.o @aR-(Vg[HI$>TJw7Kb+VfYQUq!@a~i=tʏpth8=w%K㋻!)HNN ?\룋"Qz>YV2 Cs[uJ^^#N"VR5^OX[pE%Ors:o} ɡJ7JP6 $0 zuOs 6c'JUTf`il-G'k0« ;[;_LQki WqpVoP6q&v;r8:RU!?,$qIJ iSPa4SoצL'P?մNfdNm-+jc$M/f|(:TQZTf8S:þ“өw|}-L._f̮=tS#,}ܯ τ?FB^,{5ŮBl͛WҘx+5ojٶ9k4.5F3 4gemv0Ƽl^_h_%|Db{й㚶隟fX DzuЂ!啣k\+_GZnN珿PKqJF0 0 iologger/__init__.pyPKyqJE5NNb iologger/module_test.pyPKkt;JC"iologger/.cache/v/cache/lastfailedPKXf;J:|z!!?' iologger/.hypothesis/examples/d11ab8b6baef3077/01ec548baccbe696PKPf;J/!!? iologger/.hypothesis/examples/d11ab8b6baef3077/20070074de316402PKPf;Jk<7\!!?#!iologger/.hypothesis/examples/d11ab8b6baef3077/31bf9e18d6132942PKPf;JYQ !!?!iologger/.hypothesis/examples/d11ab8b6baef3077/363af9b65c099c60PKPf;J!!?"iologger/.hypothesis/examples/d11ab8b6baef3077/3b3bd7f3f5fe614bPKPf;J/f!!?"iologger/.hypothesis/examples/d11ab8b6baef3077/55fb667caede5e32PKPf;J!!?#iologger/.hypothesis/examples/d11ab8b6baef3077/5d5a3d8c9ff6583cPKPf;J+''?#iologger/.hypothesis/examples/d11ab8b6baef3077/5fa4fa5f4dbe5909PKPf;J%!!?$iologger/.hypothesis/examples/d11ab8b6baef3077/6f70561bd02b37f0PKPf;J`!!?$iologger/.hypothesis/examples/d11ab8b6baef3077/748ea665e48eca7cPKPf;JϺr0!!?%iologger/.hypothesis/examples/d11ab8b6baef3077/799e1b536e553f23PKPf;JKeL!!?%iologger/.hypothesis/examples/d11ab8b6baef3077/8e05ec1399bc61edPKPf;J|a<a<8)iologger/.hypothesis/unicodedata/8.0.0/charmap.pickle.gzPK!H|&Ub>fiologger-1.1.6.dist-info/WHEELPK!Hq!fiologger-1.1.6.dist-info/METADATAPK!H?2  iiologger-1.1.6.dist-info/RECORDPK< yn