Skip to main content
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

# Import 
from kubi_ecs_logger import Logger, Severity

# Set some defaults in the start of your app
# If in development mode the lib will output formatted json.
Logger().dev = True
# The minimum level of severity for outputing. E.g. If set to INFO then DEBUG logs will not 
# be printed to standard out
Logger().severity_output_level = Severity.INFO
# Set default key/value pairs for the different classes that will always be appended before final output
Logger().defaults = {
    "event": {
        "test": "test value"
    }
}

# Log loaded configuration
Logger().event(
    category="configuration",
    action="configuration loaded",
    dataset="The configuration is loaded from config.yaml"
).out(severity=Severity.INFO)

# Output
# {
#   "@timestamp": "2019-07-11T15:11:03.193759+00:00",
#   "event": {
#     "action": "configuration loaded",
#     "category": "configuration",
#     "dataset": "The configuration is loaded from config.yaml",
#     "test": "test value"  # From defaults
#   },
#   "logline": {
#     "level": "INFO"
#   }
# }

# Here is a little bit bigger example
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)

# And here is the output of this one
# {
#   "@timestamp": "2019-07-11T15:15:48.896921+00:00",
#   "event": {
#     "action": "request received",
#     "category": "requests",
#     "test": "test value"  # From defaults
#   },
#   "httpresponse": {
#     "status_code": "200"
#   },
#   "logline": {
#     "level": "INFO"
#   },
#   "source": {
#     "ip": "123.251.512.152"
#   },
#   "url": {
#     "domain": "test.com",
#     "path": "/test"
#   }
# }

Dependencies

name version
marshmallow 3.15.0

Metadata

Release files for kubi-ecs-logger 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubi-ecs-logger 0.1.3
File Size Uploaded Provenance Actions
kubi_ecs_logger-0.1.3.tar.gz 17.2 kB Without provenance Details for kubi_ecs_logger-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kubi-ecs-logger 0.1.3
File Interpreter ABI Platform Actions
kubi_ecs_logger-0.1.3-py3-none-any.whl Python 3 none any Details for kubi_ecs_logger-0.1.3-py3-none-any.whl

Total release size: 41.0 kB

Release files / kubi_ecs_logger-0.1.3.tar.gz

Download URL kubi_ecs_logger-0.1.3.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0ff28787e494b99f78b1f7388b46e60f4456328bef4e72c2b9687e737b41f900
BLAKE2b-256 checksum
How to use checksums
ba15dec980f3801ea14cbf8c6a7a406c028ee5759999735049d149124c0d58ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / kubi_ecs_logger-0.1.3-py3-none-any.whl

Download URL kubi_ecs_logger-0.1.3-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a7e1dc80c46c926a3bed825fa3f9c99a02748f93ba4d8af89c96fac33a337b2
BLAKE2b-256 checksum
How to use checksums
89498b9c3357363d95007f07d3f0d581e360e018062612e91bfbffc15cd4d1d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for kubi-ecs-logger 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page