Skip to main content

A highly customizable logging library for Python.

Project description

Logery

A highly customizable logging library for Python.

Installation

Install the package using pip:

pip install logery

Quick Start

To get started, you need to generate the configuration files. You can do this by running the following command in your terminal:

logery --dotenv .env --json logging.conf.json

This will create two files:

  • .env: Contains environment variables for configuring the logger.
  • logging.conf.json: A JSON file with the detailed logging configuration.

Now you can start using the logger in your Python code:

from logery import get_logger

logger = get_logger("my_app")

logger.info("This is an informational message.")
logger.warning("This is a warning message.")
logger.error("This is an error message.")

Customization

You can customize the logging configuration by editing the logging.conf.json file. This file allows you to change formatters, handlers, filters, and more.

For example, you can add a new handler to send logs to a different file:

{
    ...
    "handlers": {
        ...
        "my_new_handler": {
            "class": "logging.FileHandler",
            "formatter": "file",
            "filename": "logs/my_app.log"
        }
    },
    "root": {
        "handlers": ["console", "queue", "my_new_handler"]
    }
}

You can also adjust the log levels in the .env file:

# .env
DEFAULT_LOGGER_LEVEL='INFO'

Advanced Usage

For more advanced customization, you can directly interact with the underlying logging library components provided by logery.

Formatters

  • JSONLogFormatter: Formats log records as JSON.

Filters

  • MaxLevelFilter: Filters log records based on a maximum log level.

Handlers

  • MyRichHandler: A rich-based handler for beautiful console output.

You can find more details on how to use these components in the logging.conf.json file.

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

logery-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: logery-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for logery-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1d1f8444fafbe1765195f5fe8bae90c50c229c678fbe72db0f1064338acfbb1b
MD5 833724fafcdea6c9789e3b1d5b25a3ab
BLAKE2b-256 2a7c9bc8a73139784c1d97ac1f44acba946842e9dea6f007dc03afeee6cb5aa7

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