Skip to main content

Simple Log Factory – a lightweight wrapper around Python's logging module.

Project description

Simple Log Factory

A lightweight wrapper around Python's built-in logging module that creates pre-configured loggers with sensible defaults.

Requires Python 3.9+

Installation

pip install simple_log_factory

Usage

Basic console logger (DEBUG level)

from simple_log_factory import log_factory

logger = log_factory("my_app")
logger.info("Application started")

Console + rotating file logger

The file log rotates daily at midnight. The time-only format (%H:%M:%S) is used automatically for the file handler since the date is encoded in the filename.

from simple_log_factory import log_factory

logger = log_factory("my_app", log_file="./app.log")

Console + static file logger

from simple_log_factory import log_factory

logger = log_factory("my_app", log_file="./app.log", rotate_file_by_day=False)

Deduplicate handlers

Prevent duplicate output when multiple loggers write to the same destination:

from simple_log_factory import log_factory

logger = log_factory("my_app", unique_handler_types=True)

LogContext and LogContextGenerators

LogContextGenerators creates context-bound loggers that inject extra key-value pairs into every log call:

from simple_log_factory import LogContextGenerators

gen = LogContextGenerators(log_name="my_app")
ctx = gen.get_logger_for_context(request_id="abc-123", user="alice")

ctx.info("Processing request")   # extra={request_id: "abc-123", user: "alice"}
ctx.error("Something went wrong")

The returned LogContext object is a frozen dataclass with attributes exception, error, warning, info, and debug.

Links

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

simple_log_factory-1.0.0.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

simple_log_factory-1.0.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file simple_log_factory-1.0.0.tar.gz.

File metadata

  • Download URL: simple_log_factory-1.0.0.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simple_log_factory-1.0.0.tar.gz
Algorithm Hash digest
SHA256 86fc6bbff7ea3eaef91b9b41b6a9ea754c56e52ea363a70e1386fe961b5d6bcb
MD5 98fb52e6f985665640548a878774648c
BLAKE2b-256 930bd284a35e187fd9c77cd2c1bd741b80994a91396a45c51016ef741ebd1291

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_log_factory-1.0.0.tar.gz:

Publisher: publish.yml on brenordv/log-factory-package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_log_factory-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_log_factory-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ea6c0793e0c227b6be6239325901f52ec3ec7abe78a28c699f3939f7facc6ae
MD5 03680a8e20ee18c2a20e4b65e7d9e4d9
BLAKE2b-256 d51f020e9072522172e0943691281a1888ac7cbdbbc76ea5a9783a29593722e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_log_factory-1.0.0-py3-none-any.whl:

Publisher: publish.yml on brenordv/log-factory-package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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