LogFix Python SDK — 에러 추적 SDK
Project description
LogFix Python SDK
Python errors, explained. The official SDK for LogFix — turn cryptic stack traces into actionable solutions in 30 seconds.
Installation
Install the SDK via pip:
pip install logfix
Quickstart
Call logfix.init() before your app starts handling requests.
import logfix
logfix.init(
api_key="logfix_api_key",
app_version="1.2.3",
)
try:
result = 1 / 0
except Exception as e:
logfix.capture_error(e, tags={"region": "ap-northeast-2"})
# Make sure all queued events are sent before exiting
logfix.flush()
Configuration Options
You can customize the SDK's behavior by passing the following options to logfix.init():
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
str |
(Required) | Your project's API Key. |
app_version |
str |
"unknown" |
Your application's version tag. |
endpoint |
str |
https://api.logfix.xyz |
URL for self-hosted servers. |
max_batch_size |
int |
50 |
Maximum number of events sent in a single batch. |
flush_interval |
float |
5.0 |
Periodic flush interval (in seconds). |
queue_size |
int |
1000 |
Internal event buffer size. |
max_retries |
int |
3 |
Maximum retry attempts for failed transmissions. |
overflow_policy |
str |
"drop_newest" |
Behavior when the queue is full: drop_newest, drop_oldest, or block. |
debug |
bool |
False |
Enable SDK internal debug logging. |
enabled |
bool |
True |
Set to False to disable capturing (useful for testing/local dev). |
Usage
Capturing Errors & Messages
# Basic error capture
logfix.capture_error(exc)
# Capture with custom level, tags, and extra context
logfix.capture_error(
exc,
level=logfix.Level.WARNING,
tags={"user_id": "usr_123"},
extra={"plan": "enterprise"},
)
# Capture a text message directly
logfix.capture_message("Deployment started", level=logfix.Level.INFO)
# Automatically recover and capture panics (useful for callbacks/threads)
logfix.recover_and_capture(lambda: risky_function())
# Context manager for automatic exception capturing
with logfix.capture_exceptions(reraise=False):
risky_operation()
Framework Integrations
LogFix provides built-in middleware for popular Python web frameworks to automatically capture unhandled exceptions.
Flask
from flask import Flask
from logfix.middleware.flask import LogfixFlaskMiddleware
app = Flask(__name__)
LogfixFlaskMiddleware(app)
FastAPI
from fastapi import FastAPI
from logfix.middleware.fastapi import LogfixFastAPIMiddleware
app = FastAPI()
app.add_middleware(LogfixFastAPIMiddleware)
Django
Add the middleware to your settings.py:
MIDDLEWARE = [
# ... other middleware ...
'logfix.middleware.django.LogfixDjangoMiddleware',
]
Testing Environment
When running unit tests or working locally, you can disable the SDK so it doesn't send events to the LogFix servers.
logfix.init(api_key="lf_test", enabled=False)
# When enabled=False, all capture functions become safe no-ops.
API Compatibility
| SDK Version | LogFix Core API | Server API |
|---|---|---|
| 1.x | v1 | v1.3 |
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logfix-1.0.0.tar.gz.
File metadata
- Download URL: logfix-1.0.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b62c495fe224899a863e2a041d908c02125811b6502b3f5332cfd5123a719cb8
|
|
| MD5 |
b42e0b834df45f4211ff8964386e4e36
|
|
| BLAKE2b-256 |
20e8f234fbf3c72fdc0eea52ee2ff6bf2ef743cc619bfd9ed72926a73099ab23
|
Provenance
The following attestation bundles were made for logfix-1.0.0.tar.gz:
Publisher:
workflow.yml on riha-cats/logfix-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logfix-1.0.0.tar.gz -
Subject digest:
b62c495fe224899a863e2a041d908c02125811b6502b3f5332cfd5123a719cb8 - Sigstore transparency entry: 1004166826
- Sigstore integration time:
-
Permalink:
riha-cats/logfix-python@860105a74eaec89c85d0d75661370b0287f70b1e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/riha-cats
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@860105a74eaec89c85d0d75661370b0287f70b1e -
Trigger Event:
push
-
Statement type:
File details
Details for the file logfix-1.0.0-py3-none-any.whl.
File metadata
- Download URL: logfix-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faa06aed34f77d92fcd9a691cfe5b18abd46cc88b2c3e19c3412d3d21e82824c
|
|
| MD5 |
09154413e4e6d4c9895e8822ab44eda8
|
|
| BLAKE2b-256 |
7eb04f9ab184ad2a162a1735cad4886ea16986730bbcdb539fb19f0a4b9b02a8
|
Provenance
The following attestation bundles were made for logfix-1.0.0-py3-none-any.whl:
Publisher:
workflow.yml on riha-cats/logfix-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logfix-1.0.0-py3-none-any.whl -
Subject digest:
faa06aed34f77d92fcd9a691cfe5b18abd46cc88b2c3e19c3412d3d21e82824c - Sigstore transparency entry: 1004166864
- Sigstore integration time:
-
Permalink:
riha-cats/logfix-python@860105a74eaec89c85d0d75661370b0287f70b1e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/riha-cats
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@860105a74eaec89c85d0d75661370b0287f70b1e -
Trigger Event:
push
-
Statement type: