Skip to main content

IFS-compliant ECS structured logger for CI/CD pipelines

Project description

IFS ECS Logger

IFS ECS Logger is a lightweight Python library providing IFS-compliant structured logging based on the Elastic Common Schema (ECS). It standardizes how logs are emitted across IFS CI/CD pipelines and automation scripts, ensuring consistent observability and easy ingestion into Elasticsearch, Kibana, or any ECS-aware platform.


Features It standardizes and how logs are emitted across IFS CI/CD pipelines and automation scripts

ensuring consistent observability and easy ingestion into Elasticsearch, Kibana, or any ECS-aware platform.

  • IFS ECS compliance — follows company formatting rules (e.g., _timestamp, host.name, structured http objects)

  • ECS 1.6.0 compatible — automatically includes ECS fields (log.level, process.pid, etc.)

  • Tekton & Kubernetes context — automatically detects and includes pipeline context when running in Tekton/K8s environments

  • Structured JSON output — perfect for Elastic, Loki, Azure Monitor, and Fluent Bit ingestion## ✨ Features

  • Log levels supported: debug, info, warning, error, critical

  • Zero configuration — simple import and use- ✅ IFS ECS compliance — follows company formatting rules (e.g., _timestamp, host.name, structured http objects)


📦 Installation

pip install ifs-ecs-logger

Usage

Standard Python Logging with IFS ECS Formatting

import logging
import sys
from ifs_ecs_logger import IFSECSFormatter

# Configure logger with IFS ECS formatting
logger = logging.getLogger("fetchConfig")
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(IFSECSFormatter())

logger.handlers.clear()
logger.addHandler(handler)

# Set logging level (DEBUG shows all messages, info/debug/warning/error/critical)
logger.setLevel(logging.DEBUG)

# Info - general progress updates
logger.info("Starting configuration fetch", extra={
    "hostName": "build-agent-01",
    "timestamp": "2025-10-21T12:34:56Z",
    "http": "200"
})

# Debug - detailed internal state, visible only if level=DEBUG
logger.debug("Preparing to fetch configuration file", extra={
    "timestamp": "2025-10-21T12:34:00Z"
})

# Warning - non-critical anomalies
logger.warning("Response took longer than expected", extra={
    "timestamp": "2025-10-21T12:35:10Z",
    "http": {"status_code": 200}
})

# Error - operational failures
logger.error("API call failed", extra={
    "http": {"status_code": 500},
    "timestamp": "2025-10-21T12:35:30Z"
})

# Critical - system-level or unrecoverable errors
logger.critical("Fetch pipeline aborted", extra={
    "timestamp": "2025-10-21T12:36:00Z",
    "hostName": "build-agent-01"
})

Alternative Handler Types (File Handler)

import logging
from ifs_ecs_logger import IFSECSFormatter

# File logging with IFS ECS formatting
logger = logging.getLogger("myapp")
file_handler = logging.FileHandler("app.log")
file_handler.setFormatter(IFSECSFormatter())
logger.addHandler(file_handler)

# Multiple handlers
console_handler = logging.StreamHandler()
console_handler.setFormatter(IFSECSFormatter())
logger.addHandler(console_handler)

logger.setLevel(logging.INFO)
logger.info("Application started", extra={"version": "1.0.0"})

Expected Output (IFS ECS-Compliant JSON)

Each log entry will be emitted as a single-line structured JSON like:

{"_timestamp":"2025-10-21T12:34:56Z","log.level":"info","message":"Starting configuration fetch","ecs.version":"1.6.0","service.name":"fetchConfig","host":{"name":"build-agent-01"},"http":{"response":{"status_code":200}}}

This flat format is optimized for log processing systems and ensures compatibility with log aggregators like ElasticSearch, Fluent Bit, Logstash, and cloud logging services.


IFS Compliance

This logger is designed to comply with IFS logging policies:

Forbidden Fields

The following fields are automatically filtered out to avoid compliance issues:

  • kubernetes (contains sensitive cluster information)
  • _id, _index, _score (Elasticsearch internal fields)
  • stream (duplicate information)

Normalized Fields

  • timestamp_timestamp (IFS standard)
  • hostNamehost.name (nested structure)
  • HTTP fields are structured as nested objects

Requirements

  • Python 3.8+
  • ecs-logging>=2.1.0
  • python-json-logger>=2.0.7

License

MIT License © IFS Golden CI Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ifs_ecs_logger-0.1.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ifs_ecs_logger-0.1.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file ifs_ecs_logger-0.1.3.tar.gz.

File metadata

  • Download URL: ifs_ecs_logger-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for ifs_ecs_logger-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3e18f1728b9f68d19fa586e91a9eb258d8a433007d8c4d027b729f7741bcf4a5
MD5 ab07e80522af2c6e99786772edbf2a45
BLAKE2b-256 215ec8e213c08fd7c5388fbdeecb3d3485abdceb63ed31b9a973a21f1f0ac5b7

See more details on using hashes here.

File details

Details for the file ifs_ecs_logger-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ifs_ecs_logger-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for ifs_ecs_logger-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 38876523e73dc3468e135a9fb94e4641765d56d4a0e684d11f091eb17c35475c
MD5 227abe904357f38c50c2628be2fd83d8
BLAKE2b-256 a7c36c63a99a6422e66b8d38bf5180d2f5405b4e03da1116dd7372d60184ba3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page