Python

The loginformant-logging package is a handler for Python's built-in logging module. It works with Flask, Django, FastAPI, or any Python 3.7+ script. No third-party dependencies required — just the standard library.

1 Install
bash
pip install loginformant-logging
2 Configure your logger
python — logging_setup.py
import logging
import os
from loginformant import LogInformantHandler

# Create the handler
handler = LogInformantHandler(
    api_url="https://app.loginformant.com",
    api_key=os.environ["LOGINFORMANT_API_KEY"],
)

# Attach to the root logger (captures all modules)
logging.basicConfig(level=logging.INFO, handlers=[
    logging.StreamHandler(),  # also print to console
    handler,
])

logger = logging.getLogger(__name__)
3 Log in your code
python
import logging

logger = logging.getLogger(__name__)

def place_order(order_id: int):
    logger.info("Order %s placed", order_id)
    try:
        # your logic
        pass
    except Exception as e:
        logger.error("Failed to place order %s", order_id, exc_info=True)

Django integration

Add the handler to Django's LOGGING dict in settings.py:

python — settings.py
import os

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
        },
        "loginformant": {
            "class": "loginformant.LogInformantHandler",
            "api_url": "https://app.loginformant.com",
            "api_key": os.environ.get("LOGINFORMANT_API_KEY", ""),
            "level": "WARNING",
        },
    },
    "root": {
        "handlers": ["console", "loginformant"],
        "level": "INFO",
    },
}

Flask integration

python — app.py
import logging
import os
from flask import Flask
from loginformant import LogInformantHandler

app = Flask(__name__)

# Attach handler to Flask's logger
handler = LogInformantHandler(
    api_url="https://app.loginformant.com",
    api_key=os.environ["LOGINFORMANT_API_KEY"],
)
app.logger.addHandler(handler)
app.logger.setLevel(logging.INFO)

Configuration options

ParameterDefaultDescription
api_urlrequiredYour LogInformant instance URL
api_keyrequiredApplication API key
batch_size50Max logs per HTTP request
flush_interval2.0Flush interval in seconds
levelWARNINGMinimum level (standard logging levels)

Log level mapping

PythonLogInformant
DEBUGDebug
INFOInformation
WARNINGWarning
ERRORError
CRITICALFatal