SMFLOG
smflog is a high-performance logging library for Python rewritten using Rust and PyO3. Serves as a drop-in extension for print() Python defaults, smflog offers much lower overhead, massive log throughput handling, and separation of log execution between output terminals and persistent SQLite storage.
Key Features & Architecture
Zero-Lag Terminal I/O (smf.printf): Replaces Python's built-in I/O mechanism with Rust FFI bindings optimized for executing large logs without triggering I/O bottlenecks.
Silent SQLite Storage (smf.printd): Isolates debugging logs and error tracebacks directly to a structured SQLite database in the OS /tmp directory without filling up the terminal stdout buffer.
Native Type Ingestion: The FFI layer handles Python data type conversion to Rust strings directly (PyBytes, NoneType, and custom classes via slots __str__).
Python Print Compatible: Supporting conventional arguments such as sep, end, file, And flush.
Technical Performance Highlights
- Overhead & Speed: Reduces I/O interrupt overhead on massive log execution by moving the formatting and text writing process to the Rust native runtime.
- Crash & Traceback Capture:
smf.printdautomatically extracts stack traces and variable metadata when catching exceptions, saving them to a structured SQLite table. - Custom design: Built on the basis of modern industrial standards in sensitive environments such as Cloud Data Center (Microservices/Serverless).
Installation
# Pip install via wheel binary (Rust Toolchain required if building from source)
pip install smflog
Usage & API Reference
- High-Speed Terminal Output (
smf.printf)
Using an interface identical toprint(), but executed in the Rust FFI layer:
import smf
# Custom separators & terminators
smf.printf("A", "B", "C", sep=" | ", end="\n---\n")
# Unpacking payload besar tanpa I/O lag
large_payload = [f"Data_{i}" for i in range(100_000)]
smf.printf(*large_payload, sep=", ")
# Stream redirection ke file object
with open("system.log", "a") as f:
smf.printf("System status: OK", file=f, flush=True)
- Rust FFI Type Handling
smfloghandle Python data type conversions efficiently at the Rust level:
class CustomObject:
def __str__(self):
return "<CustomObject String Representation>"
# Handles PyBytes natively (escaped)
bytes = b"Hello\nWorld\x00"
smf.printf("Raw Bytes:", bytes)
# Handles NoneType & Custom Objects via __str__ slot
smf.printf("None Type:", None)
smf.printf("Custom Class:", CustomObject())
- Isolated SQLite Debug Logging (smf.printd)
Save debug state and traceback to SQLite in OS temporary directory (/tmp):
try:
result = 10 / 0
except Exception as e:
# Automatically saved in SQLite without polluting the terminal stdout
smf.printd("Division failed", e, level="ERROR")
Technical Architecture & PyO3 Integration
smflog designed as a high-performance C-Extension that bridges Python Global Interpreter Lock (GIL) with Rust Native Concurrency/I/O Engine.
+---------------------------------------------------------------------------+
| Python Layer |
| smf.printf(*args, sep, end, file, flush) smf.printd(*args, level) |
+-------------------------------------+-------------------------------------+
| PyO3 FFI Boundary
+-------------------------------------v-------------------------------------+
| Rust Native Engine (smf) |
| |
| +--------------------+ +--------------------+ |
| | Fast Type Resolver | | Traceback Extractor| |
| | (PyBytes/PyStr) | | (PyErr/Exception) | |
| +---------+----------+ +---------+----------+ |
| | | |
| v v |
| +--------------------+ +--------------------+ |
| | Direct OS stdout / | | SQLite Connection | |
| | BufWriter Engine | | Pool (WAL Mode) | |
| +---------+----------+ +---------+----------+ |
+-------------------|----------------------------------|--------------------+
v v
System Terminal OS /tmp/smflog/log.db (0o700)
- PyO3 Type Ingestion & FFI Conversion
Crucial points in performancesmflogis how Python data types are converted to Rust without excessive memory allocation overhead:
PyBytesIngestion: Caught usingobj.downcast::<PyBytes>(). Byte streams are processed directly at the Rust buffer level and non-printable characters are escaped automatically.NoneTypeIsolation: Evaluated directly with C API preprocessing viaobj.is_none(), avoiding Python attribute calls.- Custom Object Handling: Call slot
__str__on C-Struct Python viaobj.str()only if the object is not a primitive type (string, int, float, bytes, bool).
- Lock & Thread Safety Design
smf.printf: Minimize reading duration GIL (Global Interpreter Lock). Concatenated string formatting (string concatenation) performed in the Rust thread layer before being executed to standard output.smf.printd: Use SQLite Write-Ahead Logging (WAL) Mode which is stored in the OS's built-in temporary directory (/tmpor%TEMP%). Log writing is done in a thread-safe manner using an isolated connection pool to avoid database locked concerns when logs are sent in parallel/massively.
SQLite Database Schema (DDL)
To ensure that the smf.printd query can execute debugging logs and large-capacity tracebacks without causing performance degradation, the following SQLite database schema is automatically applied during module initialization:
-- Database Location: OS Temporary Directory (e.g., /tmp/smflog/log.db)
-- journal mode = WAL (Write Concurrency)
-- synchronous = NORMAL (Balanced Durability)
-- temp_store = MEMORY (RAM Temp Storage)
CREATE TABLE IF NOT EXISTS system_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp REAL,
level TEXT,
label TEXT,
payload TEXT,
traceback TEXT,
caller_info TEXT
);",
SQLite Log Schema (smf.printd)
Log data is stored in the OS temporary database with the following schema:
| Field | Type | Description |
|---|---|---|
| timestamp | DATETIME | Time the log was created (ISO-8601 UTC) |
| level | TEXT | Log severity (DEBUG, INFO, ERROR, WARN) |
| label | TEXT | Taken from the first string |
| payload | TEXT | Argument fusion result string |
| traceback | TEXT | Captured Python exception stack trace (If there are) |
| caller_info | TEXT | Location of the script caller that caused the error |
License
This tool is distributed under the GPL License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 smflog-1.0.6.tar.gz.
File metadata
- Download URL: smflog-1.0.6.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96e7c128210d6d2cbb76d4b86b7adfaffcb445e08f490f10f763c49393a76280
|
|
| MD5 |
051e3d0b4479186a12a6052280c0cba0
|
|
| BLAKE2b-256 |
47139b7f99a3c4c0be7298f1b0540e485524db7ecd00aaeb5dc41c75c4762a7a
|
Provenance
The following attestation bundles were made for smflog-1.0.6.tar.gz:
Publisher:
test-build-and-release.yaml on StormWorld0/smflog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smflog-1.0.6.tar.gz -
Subject digest:
96e7c128210d6d2cbb76d4b86b7adfaffcb445e08f490f10f763c49393a76280 - Sigstore transparency entry: 2448353472
- Sigstore integration time:
-
Permalink:
StormWorld0/smflog@75bac841b18007ece819ef158dcc71409b250f89 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/StormWorld0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test-build-and-release.yaml@75bac841b18007ece819ef158dcc71409b250f89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file smflog-1.0.6-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: smflog-1.0.6-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43e0bc7097015e190587245765c94bf997d65b94553dc3d93adc2f537e996d52
|
|
| MD5 |
2aded1681cfa14bdbaf38bc91cd42a4b
|
|
| BLAKE2b-256 |
c5feee427f6a5f364bf79dc6944bf972b5a996d5ae039252ae4be3761dd39013
|
Provenance
The following attestation bundles were made for smflog-1.0.6-cp39-abi3-win_amd64.whl:
Publisher:
test-build-and-release.yaml on StormWorld0/smflog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smflog-1.0.6-cp39-abi3-win_amd64.whl -
Subject digest:
43e0bc7097015e190587245765c94bf997d65b94553dc3d93adc2f537e996d52 - Sigstore transparency entry: 2448353931
- Sigstore integration time:
-
Permalink:
StormWorld0/smflog@75bac841b18007ece819ef158dcc71409b250f89 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/StormWorld0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test-build-and-release.yaml@75bac841b18007ece819ef158dcc71409b250f89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file smflog-1.0.6-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: smflog-1.0.6-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e8914885440709538fc90cb1900badf4462ee752a350c6c27836a2bb9f71035
|
|
| MD5 |
ac2de0f24bf85d78810a13c940bc1100
|
|
| BLAKE2b-256 |
f9c94d6b6b075cc0deb6a1e97148763ba1add1693dac0c913b5610e4548b2a1f
|
Provenance
The following attestation bundles were made for smflog-1.0.6-cp39-abi3-manylinux_2_34_x86_64.whl:
Publisher:
test-build-and-release.yaml on StormWorld0/smflog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smflog-1.0.6-cp39-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
3e8914885440709538fc90cb1900badf4462ee752a350c6c27836a2bb9f71035 - Sigstore transparency entry: 2448355400
- Sigstore integration time:
-
Permalink:
StormWorld0/smflog@75bac841b18007ece819ef158dcc71409b250f89 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/StormWorld0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test-build-and-release.yaml@75bac841b18007ece819ef158dcc71409b250f89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file smflog-1.0.6-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: smflog-1.0.6-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
443bf50adee69ed116c35c47dce60fd6ce7693944f81793d0e82acbff61236d4
|
|
| MD5 |
ac00de97e41ec33cfd36aa28b7aeb0ed
|
|
| BLAKE2b-256 |
510023c902b2b20aaf9083330183c07cdfe3601f1806544059aad92d42830f0b
|
Provenance
The following attestation bundles were made for smflog-1.0.6-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
test-build-and-release.yaml on StormWorld0/smflog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smflog-1.0.6-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
443bf50adee69ed116c35c47dce60fd6ce7693944f81793d0e82acbff61236d4 - Sigstore transparency entry: 2448354683
- Sigstore integration time:
-
Permalink:
StormWorld0/smflog@75bac841b18007ece819ef158dcc71409b250f89 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/StormWorld0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test-build-and-release.yaml@75bac841b18007ece819ef158dcc71409b250f89 -
Trigger Event:
push
-
Statement type: