Skip to main content

Comprehensive function logging with async support and sensitive data protection

Project description

PyFuncLog

Comprehensive function logging with automatic sensitive data protection.

Features

  • 🕵️‍♂️ Automatic Variable Capture: Captures all local variables and function arguments
  • 🔒 Sensitive Data Protection: Automatically masks passwords, tokens, API keys, etc.
  • 🎯 Flexible Decorators: Choose what to log - everything, returns, or just locals
  • 📝 Structured Logging: JSON-formatted logs with clear structure
  • 🚀 Easy Integration: Simple decorator-based approach

Installation

pip install pyfunclog

usage example:

import asyncio
from pyfunclog import async_secure_log_function

@async_secure_log_function()
async def fetch_data(api_key: str, user_id: int):
    # api_key will be automatically masked
    await asyncio.sleep(0.1)
    result = {"user_id": user_id, "data": "sample"}
    return result

# Or use universal decorator for both sync and async
from pyfunclog import universal_log

@universal_log
async def async_function(x):
    return x * 2

@universal_log
def sync_function(x):
    return x * 2

fastapi integration

from fastapi import FastAPI
from pyfunclog import FastAPILoggingSupport, async_secure_log_function

app = FastAPI()
logging_support = FastAPILoggingSupport()
logging_support.middleware(app)  # Add request/response logging

@app.get("/users/{user_id}")
@async_secure_log_function()
async def get_user(user_id: int, token: str):
    # token will be automatically masked
    return {"user_id": user_id, "name": "John Doe"}

configure logging

from pyfunclog import configure_logging

# Configure logging
configure_logging(
    level="DEBUG",
    format_string='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    filename="app.log"
)

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

pyfunclog-2.0.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

pyfunclog-2.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file pyfunclog-2.0.1.tar.gz.

File metadata

  • Download URL: pyfunclog-2.0.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pyfunclog-2.0.1.tar.gz
Algorithm Hash digest
SHA256 bfbb92946a0bc1dac710ea14a2dec842af7a7db3822e54fc9a1d8230800e963e
MD5 37500dabcff5f0152e644b8bea241efe
BLAKE2b-256 157f4d5fa178459c1b89374026f74530981eebba3e06ae1d4307414996dce57a

See more details on using hashes here.

File details

Details for the file pyfunclog-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyfunclog-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pyfunclog-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81d5a522095216be64765e38e62a1f7ab362a10df82b85f4aee4e61ad1807b52
MD5 dcc8add98f4e0ed0e48537ac6cf3d966
BLAKE2b-256 9a33f5d645394ba48e87c9c99202e7f6d4d194e973c59592061fc205e9b25e0e

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