Skip to main content

A Python logging library designed to replace traditional logging mechanisms using decorators and modules.

Project description

Logease

Logease is a lightweight Python library designed to simplify and enhance logging by eliminating the need for traditional loggers. With Logease , you can effortlessly integrate logging into your applications using decorators and modules. The library leverages the Singleton pattern to ensure that your logging system is efficient, centralized, and easy to manage.


Key Features:

  • Singleton Logger : Initialize your logger once and use it throughout your application.
  • Decorator Support : Easily add logging to your functions and methods with various decorators.
  • Modular Design : Use the Logger module to customize and extend logging capabilities as needed.
  • Detailed Logging : Provides detailed logging options including function calls, execution times, exceptions, and parameter types.
  • JSON Logging : Log details in JSON format for structured data.

Logease aims to streamline the logging process, making it more intuitive and less intrusive. Say goodbye to the clutter of traditional loggers and embrace a cleaner, more modern approach with Logease .

Installation

To install Logease , use pip:

pip install logease

Usage

Basic Example

Initialize the logger and use it with a decorated function:

from logease.decorators import function_tracer
from logease.modules import Logger

@function_tracer()
def example_function(param):
    # Function logic here
    return f"Received {param}"

if __name__ == "__main__":
    logger.info("Starting application...")
    result = example_function("Logease")
    logger.info(f"Result: {result}")
    logger.info("Application finished.")


Customizing the Logger

You can customize the logger by passing configurations to the Logger module:

from logease.modules import Logger

# Custom logger with specific settings
logger = Logger(level="DEBUG")

logger.debug("This is a debug message")

Using Decorators

Logease provides several decorators for detailed logging:

  • @input_output_tracer : Logs function calls with arguments and return values.
  • @execution_time_tracer : Logs the execution time of functions.
  • @exception_tracer : Logs any exceptions raised by functions.
  • @param_type_tracer : Logs the types of function parameters.
  • @detailed_tracer : Logs detailed function execution information including arguments, keyword arguments, return values, and exceptions.
  • @as_json_tracer : Logs function execution details in JSON format.

Examples:

from logease.decorators import input_output_tracer, execution_time_tracer, exception_tracer

@input_output_tracer()
def add(a, b):
    return a + b

@execution_time_tracer()
def slow_function(a, b):
    time.sleep(2)
    return a + b

@exception_tracer()
def risky_function(x):
    return 1 / x

Using with Classes

Logease also supports class-level logging:

from logease.decorators import class_method_tracer, constructor_tracer, property_getter_tracer

@constructor_tracer
class MyClass:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    @class_method_tracer()
    def class_method(cls, a):
        return a * 2

    @property
    @property_getter_tracer("x")
    def x(self):
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

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

logease-0.2.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

logease-0.2.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file logease-0.2.0.tar.gz.

File metadata

  • Download URL: logease-0.2.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for logease-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2db59ef315c4358fb3e73e17787b60a949662191de527708dbf962bc8ff7edb8
MD5 b209d3f3645de2c4925656ff7dd83ecb
BLAKE2b-256 a742a77826f2d647821aa41748d9b6d815a3d7425a9f9a9545bf4369645491b8

See more details on using hashes here.

File details

Details for the file logease-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: logease-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for logease-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5796aea1e293eecf616b0f9e165ea97c2810f02b013ce11ed41230f91ff16671
MD5 4f46b081b391b088d51e3195c0cf3dce
BLAKE2b-256 c1d7616fa6a6206a9c62f32841b3d2b9ae80732f74d6f8bfd2e4737d32db8213

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page