Decorator for logging functions and coroutines
Project description
AtLog
A simple logging decorator for functions and coroutines.
Installation
pip install atlog
Usage
It is recommended to create a file-level binding to log_func which you then use on the objects you wish to log:
import logging
from atlog import log_func
logging.basicConfig(filename="example.log", level=logging.DEBUG)
logger = logging.getLogger()
log = log_func(logger)
@log
def hello(name):
return f"Hello, {name}."
class Greeter:
@log
def __init__(self, name):
self.greeting = f"Hello, {name}."
@log
def greet(self):
print(self.greeting)
if __name__ == "__main__":
print(hello("John"))
Greeter("John").greet()
This will produce the following example.log:
DEBUG:root:Calling hello(name)
DEBUG:root:hello is defined in path/to/example.py on line 8
DEBUG:root:Arguments: 'John'
DEBUG:root:hello returned 'Hello, John.'
DEBUG:root:Calling __init__(self, name)
DEBUG:root:__init__ is defined in path/to/example.py on line 14
DEBUG:root:Arguments: <__main__.Greeter object at 0x000001E95F84FDF0>, 'John'
DEBUG:root:__init__ returned None
DEBUG:root:Calling greet(self)
DEBUG:root:greet is defined in path/to/example.py on line 18
DEBUG:root:Arguments: <__main__.Greeter object at 0x000001E95F84FDF0>
DEBUG:root:greet returned None
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
AtLog-1.0.0.tar.gz
(3.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
AtLog-1.0.0-py3-none-any.whl
(3.8 kB
view details)
File details
Details for the file AtLog-1.0.0.tar.gz.
File metadata
- Download URL: AtLog-1.0.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cd4eeaf57147ba870a000fcd77fb3b6c1a2fe65e2eb609f59c0b99a86152281
|
|
| MD5 |
5561698877f48a889567df2d3b69182f
|
|
| BLAKE2b-256 |
a3c9728f5669ce3d1cf5df39023565ee49074afec170947c01f38686b9855a33
|
File details
Details for the file AtLog-1.0.0-py3-none-any.whl.
File metadata
- Download URL: AtLog-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2207fc4859e7a82005d9e358a59710164bd9d610eaf20a7f2fce949362908088
|
|
| MD5 |
4c07181d8a1990781878008349744814
|
|
| BLAKE2b-256 |
a3945e459b01a329fadc4f02c0253097378034845e1881ed70d2726c403b53bb
|