Your project description goes here
Project description
Your project description goes here
Documentation
The full documentation is at https://frame_logging.readthedocs.io.
Quickstart
Install Frame Logging:
pip install frame_logging
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'frame_logging.apps.FrameLoggingConfig',
...
)
Create a class to format your extra logging kwargs
#
class FrameFormatterExample(FrameFormatter):
# format methods
@classmethod
def get_format_behaviour(cls):
return OrderedDict([
('customer_id', cls.format_customer_id),
])
@classmethod
def format_customer_id(cls, customer_id):
return "customer_id={}".format(customer_id)
# then if you need to, you can add new method to transform extra kwargs
# transform methods
@classmethod
def get_transform_kwargs_methods(cls):
return {
'order': cls.transform_order,
}
@classmethod
def transform_order(cls, order, **kwargs):
kwargs['customer_id'] = order.customer['id']
return kwargs
Configure frame loggin in your settings.py
# mandatory, if you do not priovide a formatter the app will crash
FRAME_FORMATTER=FrameFormatterExample()
# optionnal, default = ' - '
FRAME_SEPARATOR='+'
Use it:
import frame_logging.log as log
class Order(object):
def __init__(self):
self.customer = {'id': 1}
log.info('Renewed contract %s', 'test', order=order)
# 'Renewed contract test - customer_id=1'))
Features
TODO
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Credits
Tools used in rendering this package:
History
0.1.0 (2017-10-26)
First release on PyPI.