Skip to main content

Structured log filtering and highlighting for terminals

Project description

philiprehberger-log-focus

Structured log filtering and highlighting for terminals.

Installation

pip install philiprehberger-log-focus

Usage

Quick Setup

from philiprehberger_log_focus import focus

logger = focus("myapp")
logger.info("Server started")
logger.warning("High memory usage")
logger.error("Connection failed")

Custom Handler

import logging
from philiprehberger_log_focus import FocusHandler

handler = FocusHandler(
    repeat_threshold=5,    # Suppress after 5 identical messages
    slow_threshold_ms=100, # Highlight slow operations
)

logger = logging.getLogger("myapp")
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

Slow Operation Highlighting

logger.info("Query completed", extra={"duration_ms": 250})
# Automatically highlighted if above slow_threshold_ms

Features

  • Color-coded output by log level (DEBUG=cyan, INFO=green, WARNING=yellow, ERROR=red, CRITICAL=magenta)
  • Repeat suppression — collapses repeated identical messages
  • Slow operation highlighting via extra["duration_ms"]

API

  • focus(name, level=DEBUG, repeat_threshold=10, slow_threshold_ms=100) — Quick setup, returns a configured logger
  • FocusHandler(repeat_threshold, slow_threshold_ms) — Custom logging handler

License

MIT

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

philiprehberger_log_focus-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

philiprehberger_log_focus-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_log_focus-0.1.1.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_log_focus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 20a583d32488c6605d002aa842119220a4799a4b72e1be6a86526d20ccf9339b
MD5 e2018a0c5321ecaf2ed2165ca192f225
BLAKE2b-256 57adced24f5934f396c651c98d0fe3a9e93a7027f6886b255e210fc4510a1e04

See more details on using hashes here.

File details

Details for the file philiprehberger_log_focus-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_log_focus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90afede17eb6028195cf270685b0c436d35770ec28fcf7e049f7dbb23abcad55
MD5 297b5f403cb195a157d6f056dcd2ee2f
BLAKE2b-256 eb257cafdbe728dd83466dd666ec7690b2ecb12c6afe7ea650c50745a1e62b90

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