pip install eliot
python
import sys
from eliot.stdlib import redirect_logging
redirect_logging(sys.stderr)
python
from eliot import start_action, to_file
to_file(open("mylog.log", "w"))
def make_http_request(url):
with start_action(action_type="http_request", url=url):
# perform HTTP request here
pass
python
from eliot import start_action, to_file
to_file(open("mylog.log", "w"))
def process_data(data):
with start_action(action_type="data_processing"):
# process data here
if data == "invalid":
action.add_failure(exception=ValueError("Invalid data"))
else:
action.add_success()
def handle_request(request):
with start_action(action_type="request_handling"):
process_data(request.data)