
This Python module makes logging easy for your application.
The logger outputs JSON formatted logs for ingesting into Elastic.
The module implements the ECS (Elastic Common Schema) specification that
can be found at for quick reference:
ECS Field Reference
Install
You can install the package from PyPi like this:
pip install kubi-ecs-logger
This package is only for Python 3.6 or newer.
Usage
from kubi_ecs_logger import Logger, Severity
Logger().dev = True
Logger().severity_output_level = Severity.INFO
Logger().defaults = {
"event": {
"test": "test value"
}
}
Logger().event(
category="configuration",
action="configuration loaded",
dataset="The configuration is loaded from config.yaml"
).out(severity=Severity.INFO)
Logger() \
.event(category="requests", action="request received") \
.url(path="/test", domain="test.com") \
.source(ip="123.251.512.152") \
.http_response(status_code=200) \
.out(severity=Severity.INFO)
Dependencies