Skip to main content

A small stdlib logging auto-configuration kit with colored multiline logs and log-once helpers.

Project description

stdlogkit

stdlogkit is a vLLM-style, vLLM-independent wrapper around Python's standard logging package.

Importing it configures logging immediately. Like vLLM, the default configuration installs a handler on a named root logger, stdlogkit, and child loggers propagate to it.

import stdlogkit

logger = stdlogkit.init_logger("stdlogkit.app")
logger.info("hello")
logger.warning_once("this warning appears once")

Default output:

INFO 06-24 12:00:01 [example.py:5] hello
WARNING 06-24 12:00:01 [example.py:6] this warning appears once

The default format intentionally does not include process name or PID, matching vLLM. Single-process and multiprocessing logs therefore use the same fields.

vLLM Compatibility

This package mirrors vLLM's logging behavior while remaining fully decoupled:

  • Uses logging.config.dictConfig.
  • Configures one named logger by default, stdlogkit, with propagate=false.
  • Child loggers such as stdlogkit.app have no handler and propagate upward.
  • init_logger(name) patches debug_once, info_once, and warning_once onto that returned logger instance.
  • *_once uses functools.lru_cache, so arguments must be hashable, as in vLLM.
  • Multiline logs are aligned with the same prefix strategy as vLLM.
  • Color constants match vLLM exactly.

Colors

The ANSI color values are identical to vLLM:

Level/field ANSI code
DEBUG \033[37m
INFO \033[32m
WARNING \033[33m
ERROR \033[31m
CRITICAL \033[35m
timestamp and file info \033[90m
reset \033[0m

Environment Variables

Variable Default Description
STDLOGKIT_CONFIGURE_LOGGING 1 Set 0 to disable auto configuration.
STDLOGKIT_LOGGING_LEVEL INFO Named logger and handler level.
STDLOGKIT_LOGGING_STREAM ext://sys.stdout Handler stream.
STDLOGKIT_LOGGING_PREFIX empty Prefix prepended to every log line.
STDLOGKIT_LOGGING_COLOR auto auto, 1, or 0.
STDLOGKIT_LOGGING_CONFIG_PATH unset Path to a JSON dictConfig file.
STDLOGKIT_LOGGER_NAME stdlogkit Named logger to configure.
NO_COLOR 0 Standard flag to disable ANSI colors.

Custom JSON Config

{
  "version": 1,
  "disable_existing_loggers": false,
  "formatters": {
    "plain": {
      "class": "stdlogkit.formatter.NewLineFormatter",
      "format": "%(levelname)s %(asctime)s [%(fileinfo)s:%(lineno)d] %(message)s",
      "datefmt": "%m-%d %H:%M:%S"
    }
  },
  "handlers": {
    "console": {
      "class": "logging.StreamHandler",
      "formatter": "plain",
      "level": "INFO",
      "stream": "ext://sys.stdout"
    }
  },
  "loggers": {
    "stdlogkit": {
      "handlers": ["console"],
      "level": "INFO",
      "propagate": false
    }
  }
}

Run with:

STDLOGKIT_LOGGING_CONFIG_PATH=/path/to/logging.json python app.py

Development

cd standalone_logging_pkg
uv venv --python 3.12
uv pip install -e ".[dev]"
PYTHONPATH=src .venv/bin/python -m unittest discover -s tests -v
uv build

Publish to PyPI

Before publishing, make sure the project name in pyproject.toml is available on PyPI and replace the placeholder author/repository metadata.

cd standalone_logging_pkg
uv build
uv publish --token "$PYPI_TOKEN"

For TestPyPI:

uv publish --publish-url https://test.pypi.org/legacy/ --token "$TEST_PYPI_TOKEN"

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

stdlogkit-0.2.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

stdlogkit-0.2.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file stdlogkit-0.2.0.tar.gz.

File metadata

  • Download URL: stdlogkit-0.2.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stdlogkit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dd95734ecce5426ae59c504c7f99ae3b5a313759e3e9728811575c6ed0c32900
MD5 4407dc755b6ed7441aa87c2fa29bec3e
BLAKE2b-256 e3c565fdfe1c896380fe2b0ab8d38c9cdfea06915b4f2ae541fd52605e664426

See more details on using hashes here.

File details

Details for the file stdlogkit-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: stdlogkit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stdlogkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 adac95083a503a10f1425174c65c1d9a2bd63553cc503ab205245940714ac4d6
MD5 bdab969e45d11ceb513bd8c2b2d513c3
BLAKE2b-256 3f5d92980d78bd61c2c7a1f1485807260706ece333151e26f6cbf97e1a42c32a

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