Package: pinlog
PinLogPinLog is a powerful driver and library integrated several logging systems. It is divided into smallest independent service units and easy to use.InstallationPinLog can be installed withpip:$ python -m pip install pinlogGet StartStep 1 - Importpinlog>>> from pinlog import helper
>>> from pinlog.log import Log
>>> from pinlog.helper import Logger, Console, Logstash, FiltersStep 2 - Add@Loggerabove the class>>> @Logger(Log.Console, Log.Logstash)
>>> class MyClass():
...     def __init__(self):
... 
...Step 3 - Usepin(str)function to mark an excution timestampDefine key or unique name topin(str)function>>> mc = MyClass()
>>> mc.pin('marker1')Step 4 - Uselatency(str1, str2)function to find out timing in milliseconds from point to pointFrom below example, to find timing of execution process from'marker1'to'marker2'by callinglatency('marker1', 'marker2')>>> time.sleep(3)
>>> mc.pin('marker2')
>>> print("--- %.8f milliseconds execution ---" % (mc.latency('marker1', 'marker2')))
--- 3001.61195 milliseconds execution ---Step 5 - Use@Filters(...)along withtrace(str1, data)functionWith placing@Filters(...)above the class and filling some attributes names you need,trace(str1, data)function will format data then return only attributes you declared. In additional the return value will be addlatencyattribute in milliseconds as well.>>> @Logger(Log.Console, Log.Logstash)
>>> @Filters('attribute1', 'attribute2', 'attribute3', 'attribute4')
>>> class MyClass():
...     def __init__(self):
... 
... data = {...}
... output = mc.trace('marker1', data)Step 6 - Finally, useunpin(str)function to reset timestamp>>> mc.unpin('marker1')
>>> mc.unpin('marker2')Moreover, Excution process times is able to traced from anywhere no matter other functions, other classes, not even other applications as below examplesTracing over 2 applicationsBelow examples show how to trace times across 2 applications. By creating the first application,class1.pyand the second application,class2.pyDeclaring Class1() inclass1.py:from pinlog import helper
from pinlog.log import Log
from pinlog.helper import Logger, Console, Logstash, Filters
import time

@Logger(Log.Console, Log.Logstash)
@Filters('username', 'firstname', 'middlename', 'lastname')
class Class1():
    
    def __init__(self):
        pass

    def function1(self, str):
        pass


c1 = Class1()
c1.pin('marker1')
time.sleep(3)
c1.pin('marker2')Declaring Class2() inclass2.py:from pinlog import helper
from pinlog.log import Log
from pinlog.helper import Logger, Console, Logstash, Filters

@Logger(Log.Console, Log.Logstash)
class Class2():

    def __init__(self):
        pass

    def function2(self, str):
        pass

c2 = Class2()
data = {
    'username': 'admin',
    'password': '1qazxsw2',
    'firstname': 'Tom',
    'lastname': 'Cruise',
    'role': 'Administrator',
    'birthdate': 'July 3, 1962',
    'department': 'Cruise/Wagner Productions'
}
output1 = c2.trace('marker1', data)
print('Output 1 : ', output1)
output2 = c2.trace('marker2', data)
print('Output 2 : ', output2)Output :Output 1 : {'username': 'admin', 'firstname': 'Tom', 'middlename': None, 'lastname': 'Cruise', 'latency': 13845.938920974731}
Output 2 : {'username': 'admin', 'firstname': 'Tom', 'middlename': None, 'lastname': 'Cruise', 'latency': 10844.847202301025}