Eliot: Logging for Complex & Distributed Systems¶
Eliot is a Python logging system that outputs causal chains of actions happening within and across process boundaries: a logical trace of the system’s operation.
$ pip install eliot
- Structured, optionally-typed log messages and actions.
- Logged actions can span processes and threads.
- Excellent support for unit testing your code’s logging.
- Optional Twisted support.
- Designed for JSON output, usable by Logstash/Elasticsearch.
- Supports CPython 2.7, 3.3, 3.4 and PyPy.
Here’s an example of using Eliot, and the output rendered by eliot-tree:
import sys from eliot import start_action, to_file import requests to_file(sys.stdout) def check_links(urls): with start_action(action_type="check_links", urls=urls): for url in urls: try: with start_action(action_type="download", url=url): response = requests.get(url) response.raise_for_status() except Exception as e: raise ValueError(str(e)) check_links(["http://google.com"], ["http://nosuchurl"])
$ python examples/linkcheck.py | eliot-tree 4c42a789-76f5-4f0b-b154-3dd0e3041445 +-- check_links@1/started `-- urls: [u'http://google.com', u'http://nosuchurl'] +-- download@2,1/started `-- url: http://google.com +-- download@2,2/succeeded +-- download@3,1/started `-- url: http://nosuchurl +-- download@3,2/failed |-- exception: requests.exceptions.ConnectionError |-- reason: ('Connection aborted.', gaierror(-2, 'Name or service not known')) +-- check_links@4/failed |-- exception: exceptions.ValueError |-- reason: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
- Why Eliot?
- Logging Messages and Tracebacks
- Configuring Logging Output
- Logging Actions and Tasks
- Logging Across Processes and Threads
- Using Types to Structure Messages and Actions
- Unit Testing Your Logging
- Using Logstash and ElasticSearch to Process Eliot Logs
- Using Eliot with Twisted
- Message Fields in Depth
- Contributing to Eliot
- What’s New