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 tiny, vLLM-independent wrapper around Python's standard logging package.

Importing it configures standard logging immediately:

import logging
import stdlogkit  # noqa: F401

logger = logging.getLogger(__name__)
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

Features

  • Uses only Python's standard logging machinery.
  • Auto-configures logging on import stdlogkit.
  • Configures the root logger by default, so normal logging.getLogger(...) calls work immediately.
  • Adds debug_once, info_once, and warning_once to standard logger instances.
  • Supports multiline log alignment.
  • Supports ANSI colors with auto, forced-on, and forced-off modes.
  • Supports custom JSON config through logging.config.dictConfig.
  • Includes optional uvicorn access-log filtering helpers.
  • Has no runtime dependency on vLLM or any other third-party package.

Environment Variables

Variable Default Description
STDLOGKIT_CONFIGURE_LOGGING 1 Set 0 to disable auto configuration.
STDLOGKIT_LOGGING_LEVEL INFO Root or named logger 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 empty Configure a named logger instead of root.
STDLOGKIT_ROOT_DIR current working directory Base path for relative file display.
STDLOGKIT_SHOW_REL_PATH debug debug, always, or never.
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"
    }
  },
  "root": {
    "handlers": ["console"],
    "level": "INFO"
  }
}

Run with:

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

Named Logger Mode

By default, stdlogkit configures the root logger. If you want behavior closer to a framework-specific logger, configure only a named logger:

STDLOGKIT_LOGGER_NAME=my_app python app.py

Then loggers under my_app.* propagate to that logger:

import logging
import stdlogkit  # noqa: F401

logger = logging.getLogger("my_app.service")
logger.info("hello")

Development

cd standalone_logging_pkg
uv venv --python 3.12
uv pip install -e ".[dev]"
.venv/bin/python -m pytest -q
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.1.0.tar.gz (11.4 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.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stdlogkit-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 54ff97fe2f8c4e70f7f0789185c693e300de796a2cf57495ef8a3f37cc636d5b
MD5 262e0e10026ee2a1ee89c878e73beb6c
BLAKE2b-256 c6ba6cc58a896746e796a6001ee26a34af2ffe3366ce174a4688477e960bd6ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stdlogkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c688a3e42a73f129345fe11479fd2d52d048a98a25db640ddbdec371a3312051
MD5 566db1314b7befd67e2c8337a5aece26
BLAKE2b-256 125e7a913f43d7b9121c43cc7e19efdb149e12f6d1a4acb19ca6c2fc33764b88

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