Skip to content

vast-enterprise/vast-log-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vast-log-python

Python structured logging library implementing the VAST logging standard, built on structlog + orjson for high performance.

Mirrors the API of vast-log-go.

Features

  • VAST standard field naming (_service, _id, _ip, _time, _level, _msg, _file)
  • JSON output via orjson (fast, sorted keys)
  • Kubernetes Downward API integration
  • Custom fields support
  • Structured, context-bound logging via structlog

Installation

pip install vast-log

Quick Start

import vast_log

cfg = vast_log.Config(
    service="my-service",
    instance_id="pod-abc123",
    ip="10.0.0.1",
    custom={"region": "us-west-2", "env": "production"},
)

logger = vast_log.new(cfg)

logger.info("service started", port=8080, version="1.0.0")
logger.warning("high memory usage", used_mb=900, limit_mb=1024)
logger.error("database connection failed", db_host="postgres:5432")

Output:

{"_file": "basic.py:14", "_id": "pod-abc123", "_ip": "10.0.0.1", "_level": "INFO", "_msg": "service started", "_service": "my-service", "_time": "2024-01-15T10:30:45.123456Z", "env": "production", "port": 8080, "region": "us-west-2", "version": "1.0.0"}

Kubernetes

import vast_log

# Reads SERVICE_NAME, POD_NAME, POD_IP from environment
cfg = vast_log.from_k8s_env()
logger = vast_log.new(cfg)

K8s Downward API env vars:

Env Var VAST Field
SERVICE_NAME _service
POD_NAME _id
POD_IP _ip

Log Levels

Level Description
DEBUG Local debugging only, not used in production
INFO Normal operation (default level)
WARNING Recoverable issues
ERROR Unrecoverable issues, service still available
CRITICAL Critical issues causing service unavailability

About

VAST standard structured logging for Python

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages