Skip to main content

colorstreak

Minimal color logging for Python terminals. Two loggers in one package:

  • Logger — zero-dependency ANSI logger that works like print()
  • RichLogger — feature-rich logger powered by Rich with tables, JSON, trees, benchmarks, and more

Instalacion

pip install colorstreak

Logger (basico)

ANSI puro, sin dependencias. Se siente como print().

from colorstreak import Logger

Logger.info("Servidor arriba")
Logger.warning("Cache fria")
Logger.error("No se pudo conectar")
Logger.success("Deploy OK")

Niveles disponibles

Metodo Color
Logger.debug() Verde
Logger.info() Azul
Logger.warning() Amarillo
Logger.error() Rojo
Logger.success() Verde
Logger.library() Magenta
Logger.step() Cyan
Logger.note() Gris
Logger.title() Azul bold
Logger.metric() Magenta

Estilos

Logger.configure(style="soft")  # "full" (default) | "prefix" | "soft"

O por variable de entorno:

export COLORSTREAK_STYLE=prefix

Compatible con print()

Logger.info("Multiple", "args", 123, sep=" | ")
Logger.warning("Sin salto...", end="")

Desactivar colores

export NO_COLOR=1

RichLogger (avanzado)

Logger con Rich para output profesional en terminal.

from colorstreak import RichLogger

log = RichLogger(style="inline")

Configuracion

log = RichLogger(
    level="DEBUG",       # nivel minimo: DEBUG, INFO, WARNING, ERROR, CRITICAL
    style="inline",      # "panel" | "inline" | "minimal"
    metadata=True,       # muestra archivo:linea en cada log
    timestamp=True,      # muestra hora
)

Niveles

log.debug("Mensaje de debug")
log.info("Servidor iniciado en puerto 8080")
log.warning("Cache expirado")
log.error("No se pudo conectar a la DB")
log.critical("Sistema de archivos lleno")
log.success("Deploy completado")
log.library("Cargando modulo: colorstreak")
log.step("Paso 1/3: Verificando...")
log.note("Nota de baja prioridad")
log.metric("loss=0.1234 acc=0.9876")
log.title("=== Seccion: Resultados ===")

Filtrado por nivel

log = RichLogger(level="WARNING")
log.debug("No se muestra")
log.warning("Esto si")

Tablas

# Desde lista de dicts
log.table([
    {"ID": 1, "Nombre": "Carlos", "Rol": "Admin"},
    {"ID": 2, "Nombre": "Maria", "Rol": "Editor"},
], title="Usuarios")

# Desde columns + rows
log.table(
    columns=["Metrica", "Valor"],
    rows=[["CPU", "42%"], ["RAM", "78%"]],
)

JSON

log.json({
    "status": "ok",
    "config": {"timeout": 30, "retries": 3},
})

Excepciones

try:
    result = 1 / 0
except ZeroDivisionError:
    log.exception("Algo salio mal")

Benchmark

with log.benchmark("Operacion pesada", slow_threshold=1.0):
    time.sleep(0.5)

Grupos

with log.group("Inicializando servicios"):
    log.info("Conectando a Redis...")
    log.success("Listo")

HTTP

log.http("GET", "/api/users", status=200, duration=0.045)
log.http("POST", "/api/login", status=201, duration=0.12)
log.http("DELETE", "/api/sessions", status=500, duration=3.2)

SQL

log.sql("""
    SELECT u.name, COUNT(o.id) as orders
    FROM users u
    LEFT JOIN orders o ON o.user_id = u.id
    WHERE u.active = true
    LIMIT 10
""")

Header (banner de inicio)

log.header(
    "Mi API",
    version="1.0.0",
    env="production",
    port=8080,
)

Variables de entorno

# Explicito: muestra solo las que pidas
log.env("DATABASE_URL", "REDIS_URL", "SECRET_KEY")

# Auto-discover: lee las variables de los archivos .env* del proyecto
log.env()

El auto-discover parsea todos los archivos .env, .env.local, .env.secret, etc. del root del proyecto. Las variables con nombres como SECRET, KEY, TOKEN, PASSWORD se enmascaran automaticamente.

Tree (estructura de directorios)

# Manual: pasa tu propio dict
log.tree("Mi Proyecto", {
    "src": {"main.py": None, "utils.py": None},
    "tests": {"test_main.py": None},
    "README.md": None,
})

# Auto-discover: escanea el proyecto desde el root
log.tree()

# Con profundidad maxima
log.tree(max_depth=2)

El auto-discover detecta el root del proyecto buscando pyproject.toml, package.json, .git, etc. Ignora carpetas como .git, __pycache__, .venv, node_modules.

Inspect

log.inspect(mi_objeto)
log.inspect(mi_objeto, methods=True)

Code

log.code("""
def fibonacci(n: int) -> int:
    if n <= 1:
        return n
    return fibonacci(n - 1) + fibonacci(n - 2)
""", title="Fibonacci", language="python")

Diff

log.diff(old_text, new_text, context="config.ini")

Panel

log.panel(
    "El servidor se reiniciara en 30 segundos.",
    title="Mantenimiento",
    style="warning",  # "info" | "warning" | "error" | "success"
)

Contadores

for request in requests:
    log.count("requests_processed")

log.count_summary(title="Resumen")

Log a archivo

log.to_file("output.log")
# A partir de aqui, todo se escribe tambien al archivo (sin colores)

Regla visual

log.rule("Seccion importante")

Requisitos

  • Python >= 3.10
  • rich (se instala automaticamente)

Metadata

Release files for colorstreak 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colorstreak 2.2.1
File Size Uploaded Provenance
colorstreak-2.2.1.tar.gz 16.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for colorstreak 2.2.1
File Interpreter ABI Platform
colorstreak-2.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / colorstreak-2.2.1.tar.gz

Download URL colorstreak-2.2.1.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
25eb20291df1e872228bb6c3066289f2e3f46ced84cb6bf77b313658d1f15a0b
BLAKE2b-256 checksum
How to use checksums
4fb81ff23232bbc374f19a86ffbb099bd90984e8d9d15f89bd64f039b8894a2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / colorstreak-2.2.1-py3-none-any.whl

Download URL colorstreak-2.2.1-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4585d1082571d8e1694853ae7c00294feb736e050d314a655188b6800fc8cbe0
BLAKE2b-256 checksum
How to use checksums
c03cc272e94bad5322a248856d5bd92c19db314172cb8884d18fd4bb9b2e7a53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for colorstreak 2.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page