AtLog-1.0.0
توضیحات
Decorator for logging functions and coroutines
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | AtLog-1.0.0 |
| نام | AtLog |
| نسخه کتابخانه | 1.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | John Blundell |
| ایمیل نویسنده | jlobblet-github@gmx.co.uk |
| آدرس صفحه اصلی | https://github.com/Jlobblet/AtLog |
| آدرس اینترنتی | https://pypi.org/project/AtLog/ |
| مجوز | - |
# 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:
```py
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
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl AtLog-1.0.0:
pip install AtLog-1.0.0.whl
نصب پکیج tar.gz AtLog-1.0.0:
pip install AtLog-1.0.0.tar.gz