🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

sift-dev-logger

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sift-dev-logger

A logging SDK for Sift Dev that supports Flask and FastAPI

2.0.1
PyPI
Maintainers
1

SIFT dev-logger (v2.0)

A lightweight Python logging SDK that provides structured logging for Flask and FastAPI applications. This new version uses a custom implementation without OpenTelemetry dependencies.

Installation

Using pip

pip install sift-dev-logger

With optional Flask support:

pip install "sift-dev-logger[flask]"

With optional FastAPI support:

pip install "sift-dev-logger[fastapi]"

With all optional dependencies:

pip install "sift-dev-logger[all]"

Features

  • Simple structured logging without dependencies on OpenTelemetry
  • Batching of logs for better performance
  • Customizable configuration through environment variables or code
  • Support for Flask and FastAPI web frameworks
  • Ability to send logs to a custom endpoint or fallback to console output

Configuration

Configure the logger via environment variables:

# Required for sending logs to a custom endpoint
export SIFT_DEV_ENDPOINT="https://your-log-endpoint.com/logs"
export SIFT_DEV_API_KEY="your-api-key"

# Optional configuration
export SIFT_DEV_SERVICE_NAME="your-service-name"
export SIFT_DEV_SERVICE_INSTANCE_ID="your-instance-id"
export ENV="production"  # or development, staging, etc.

Or configure programmatically:

from sift_dev_logger import configure, SiftDevConfig

# Configure once at application startup
configure(SiftDevConfig(
    service_name="my-service",
    service_instance_id="instance-1",
    endpoint="https://your-log-endpoint.com/logs",
    api_key="your-api-key",
    env="production",
    batch_size=10,  # Number of logs to batch before sending
    batch_delay_millis=5000  # Maximum time to wait before sending a batch
))

Basic Usage

from sift_dev_logger import getLogger

# Get a logger (automatically configured with SiftDevHandler)
logger = getLogger("my_module")

# Log messages with different severity levels
logger.info("This is an informational message")
logger.warning("This is a warning message")
logger.error("This is an error message")

# Log with additional context
logger.info("User logged in", extra={"user_id": "12345", "ip_address": "192.168.1.1"})

# Log with structured data
logger.info("API request completed", extra={
    "request_id": "req-abc-123",
    "duration_ms": 42,
    "status_code": 200,
    "user": {
        "id": "user-123",
        "role": "admin"
    }
})

# Make sure all logs are flushed before application exit
from sift_dev_logger import flush_logs
flush_logs()

How to build and publish

  • Install build tools:

    pip install build
    
  • Build the package:

    python -m build
    
  • Test the package locally:

    pip install sift_dev_logger-0.1.0.tar.gz
    
  • Upload to PyPI (you'll need to create an account first):

    python -m twine upload dist/*
    

Key Features

  • Optional Dependencies: Users can install just what they need (core, Flask, or FastAPI support).
  • Modern Build System: Uses hatchling for a clean, modern build.
  • Clear Documentation: README shows installation and basic usage.
  • Version Management: Easy to update version in one place.
  • Development Tooling: Development dependencies separated from runtime requirements.

Keywords

dev

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts