Have you ever wanted to have logging decorators for logging function calls and for automatic creation of logger object in class, based on class hierarchy.
If your answer is true, here is my implementation https://github.com/offlinehacker/PyLogDecorate. There is very nice option i’ve implemented called subdecorate, enabling for functions in derived classes being logged, even if decorator is only applied on base class function.
This logging decorator implementation can be easily extended.
- Install:
python setup.py install or easy_install PyLogDecorate.
Example code:
from log import LogCall, LogClass
@LogCall()
def test():
print "x"
@LogClass({"subdecorate": True})
class test1(object):
name="kekec"
name2="kekec2"
@LogCall({"subdecorate": True, "tracename": "tracetest", "traceattr": "name"})
def test(self):
pass
@LogCall({"subdecorate": True, "tracename": "tracetest", "traceattr": "name2"})
def test2(self):
self.logger.debug("Inside base class!")
@LogClass()
class test2(test1):
def __init__(self):
pass
def test(self):
self.logger.debug("Inside funtion.")
self.test2()
@LogClass()
class test3(test2):
def __init__(self):
pass
def test(self):
self.logger.debug("Inside funtion2.")
self.test2()
test()
b=test3()
c=test2()
b.test()
c.test()
Metadata
Release files for PyLogDecorate 0.333
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyLogDecorate-0.333.tar.gz | 4.2 kB | Without provenance | Details for PyLogDecorate-0.333.tar.gz |
Release files / PyLogDecorate-0.333.tar.gz
| Download URL | PyLogDecorate-0.333.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53eb35aa89596d68ae9feb392d62d437db9fb6fbdd34f5a5f5e6b17634b4c603
|
|
BLAKE2b-256 checksum How to use checksums |
548ee6d1a262f52128de9bf117fad68e12164a1d83de005010139c39f881ed03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PyLogDecorate 0.333
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.