Skip to main content

A Python library for local logging with advanced features

Project description

loglocal

loglocal is a Python library for advanced local logging, built on top of loguru and pydantic. It provides configurable logging with support for both synchronous and asynchronous function decorators, file rotation, retention, and more.

Features

  • Easy-to-use logger with sensible defaults
  • Configurable via environment variables and pydantic models
  • Supports both console and file logging
  • Decorators for logging function execution (sync and async)
  • File rotation, retention, compression, and serialization

Installation

You can install loglocal via pip:

pip install loglocal

Or if you prefer to use uv (Universal Virtual Environment):

uv add loglocal

Usage

from loglocal import logger

logger.info("Hello from loglocal!")


@logger.wrap
def my_function(x, y):
  return x + y


@logger.wrap
async def my_async_function(x, y):
  return x * y

API Reference

logger

A class-level property that returns a configured LogLocal instance using default settings.

LogLocal

Extends loguru.Logger with additional configuration and decorators.

Methods

  • from_config(config: LogLocalConfig, **kwargs) -> LogLocal
    Create a logger instance from a LogLocalConfig object.

  • wrap(func=None)
    Decorator to log execution of sync or async functions.

Example

from loglocal import Logger, logger
from loglocal.models import LogLocalConfig

custom_logger = Logger(
    config=LogLocalConfig(
        ...  # Custom configuration parameters
    )
)
logger.info("Logging with default config")

Configuration

Environment Variables

  • LOGLOCAL_PATH: Path to the log file (default: logs/app.log)

You can customize logging behavior by passing a custom LogLocalConfig:

  • log_path: Path to log file (default: logs/app.log) # overrides LOGLOCAL_PATH environment variable
  • log_format: Log message format
  • log_level: Logging level (default: DEBUG)
  • log_opt: Additional options for the logger (e.g., exception, depth, colors, etc.) of type LogLocalOptions
  • log_config: Pydantic model for additional configuration options (e.g., file rotation, retention, compression, etc.) of type LogConfig

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

loglocal-1.0.4.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

loglocal-1.0.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file loglocal-1.0.4.tar.gz.

File metadata

  • Download URL: loglocal-1.0.4.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for loglocal-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b4bb7b99ab82967bfd6d4972ed48adbaa020f1fce125b6969aed31a026e7628b
MD5 a278a1f12a5b5c528840db81752bfcde
BLAKE2b-256 ad3b70378ab18e45a8abbd052a29043c86644b6bd1bade77e5f33d2b616d6410

See more details on using hashes here.

Provenance

The following attestation bundles were made for loglocal-1.0.4.tar.gz:

Publisher: publish.yml on sabadia/loglocal

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

File details

Details for the file loglocal-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: loglocal-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for loglocal-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9fcfc16b678fc241c5d237cd16ee3786223491aa88caf2d2acf957c33abfaf5d
MD5 a1bba06ca9539b630b5f803f449a7460
BLAKE2b-256 fa668def9c00b85a80aa8582e0af56bef6c0cf41e71fdf6fc419019e338f97ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for loglocal-1.0.4-py3-none-any.whl:

Publisher: publish.yml on sabadia/loglocal

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