Skip to main content

Utilities for logging with orjson serialization and advanced features

Project description

ss-utils-logging

A Python logging utility package with orjson serialization and advanced configuration features.

Features

  • ORJSON Serialization: High-performance JSON logging with orjson
  • YAML Configuration: Easy logging setup using YAML configuration files
  • Merging Logger Adapter: Advanced adapter that properly merges extra fields (fixes Python <3.13 limitation)
  • Console & JSON Formatters: Flexible formatting options for different output needs
  • Config File Generation: Automatically generate example configuration files

Installation

uv add ss-utils-logging

Quick Start

# [one-time] Generate example configuration files in `config/` folder
# This creates example YAML configuration files (logging.yaml and logging.prod.yaml) that you can customize for your needs.
uv run ss-utils-logging config --no-overwrite
from ss_utils_logging import configure_logging, get_logger, generate_config_files

# Configure logging with YAML file
configure_logging("config/logging.yaml")

# Set up a logger with extra context
logger = get_logger(__name__, extra={"service": "my-app", "version": "1.0.0"})

# Log with additional context (optional)
logger.info("Processing request", user_id=123, action="login")

Key Components

MergingLoggerAdapter

Fixes the Python <3.13 limitation where LoggerAdapter doesn't properly merge extra fields from both the adapter and individual log calls.

Formatters

  • ConsoleFormatter: Human-readable console output
  • ORJSONFormatter: High-performance JSON output using orjson

Configuration Management

  • configure_logging(): Set up logging from YAML configuration
  • generate_config_files(): Create example configuration files
  • get_logger(): Get logger instances with optional extra context

Test notes

  • Tested only on macos

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

ss_utils_logging-0.0.10.tar.gz (65.3 kB view details)

Uploaded Source

Built Distribution

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

ss_utils_logging-0.0.10-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file ss_utils_logging-0.0.10.tar.gz.

File metadata

  • Download URL: ss_utils_logging-0.0.10.tar.gz
  • Upload date:
  • Size: 65.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for ss_utils_logging-0.0.10.tar.gz
Algorithm Hash digest
SHA256 386d290845553846238e31226742bcfc632180bc6854817025ac43d8cdf99bd8
MD5 0a52b02db53ab21cf93528509761b74b
BLAKE2b-256 f0e8f4afd5a127a4e99f99e51b3884704c3c439fad11357798afa0f1fa8425cc

See more details on using hashes here.

File details

Details for the file ss_utils_logging-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for ss_utils_logging-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1e5b5a48d4b98ff1817e9116aec5cd1d9c9264a427cd7005a1e80d5429b741cf
MD5 2c87a6eee338a3b3e0684c901b1447ac
BLAKE2b-256 c0d7e2fb7f92f2d6f281040cd6954a1c7a51e5c1f3f006248675bc91373d0c09

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