Skip to main content

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.

Metadata

Release files for logease 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logease 0.2.0
File Size Uploaded
logease-0.2.0.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for logease 0.2.0
File Interpreter ABI Platform
logease-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.7 kB

Release files / logease-0.2.0.tar.gz

Download URL logease-0.2.0.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2db59ef315c4358fb3e73e17787b60a949662191de527708dbf962bc8ff7edb8
BLAKE2b-256 checksum
How to use checksums
a742a77826f2d647821aa41748d9b6d815a3d7425a9f9a9545bf4369645491b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Release files / logease-0.2.0-py3-none-any.whl

Download URL logease-0.2.0-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5796aea1e293eecf616b0f9e165ea97c2810f02b013ce11ed41230f91ff16671
BLAKE2b-256 checksum
How to use checksums
c1d7616fa6a6206a9c62f32841b3d2b9ae80732f74d6f8bfd2e4737d32db8213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page