Skip to main content

Universal logging function for Python — tablog() works everywhere

Project description

tablogger

Python SDK for tablogger — one function, every language, one terminal.

tablog() is a drop-in replacement for print() that routes your logs to a single unified terminal alongside your JS/Rust services. Run npx tablogger once and see everything in one place.

[React]    button clicked
[FastAPI]  GET /api/users 200 18ms
[Python]   processing 42 items       main.py:18
[Python]   done in 4ms               main.py:31

PyPI license


Installation

pip install tablogger

With framework extras:

pip install tablogger[fastapi]
pip install tablogger[flask]

Quick start

1. Start the terminal

npx tablogger

2. Log from Python

from tablog import tablog

tablog("server started")
tablog("query result:", {"rows": 42})

Logs appear instantly in the tablogger terminal with source label, file, and line number.


API

tablog(*args)

Drop-in replacement for print(). Accepts any number of arguments — strings are passed through, everything else is JSON-serialized.

from tablog import tablog

tablog("user logged in")
tablog("query result:", {"rows": 42})
tablog("count:", 100)

init(source, port)

Call once at startup to set a custom source label or port. Optional — auto-detects the running framework if not called.

from tablog import init

init(source="payments-service", port=4242)

Framework integrations

FastAPI

from tablog import tablog
from tablog.middleware import TablogMiddleware

app.add_middleware(TablogMiddleware, source="FastAPI")

@app.get("/api/users")
async def get_users():
    tablog("fetching users")
    return {"users": users}

Flask

from tablog.middleware import TablogFlaskMiddleware

TablogFlaskMiddleware(app)

LangChain / LlamaIndex

from tablog.langchain import TablogCallbackHandler

handler = TablogCallbackHandler(source="MyRAGApp")
chain = RetrievalQA.from_chain_type(llm=llm, callbacks=[handler])

Log levels

tablog("all good")                           # default
tablog("cache miss rate high", level="warn")  # yellow
tablog("payment failed", level="error")       # red

Behaviour

  • Fire and forgettablog() returns immediately; sending is async in a background thread.
  • Auto-reconnect — if the tablogger server isn't running yet, messages queue up and flush once it starts.
  • Fallback — always echoes to stdout via print() even when the server is unreachable.
  • Auto-detection — detects FastAPI, Flask, Django, and other frameworks automatically.

Environment variables

Variable Default Description
TABLOG_PORT 4242 Port of the tablogger server
TABLOG_SOURCE auto-detected Override source label

Other SDKs

Language Package
JavaScript / TypeScript npmjs.com/package/tablogger
Rust crates.io/crates/tablogger

License

MIT

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

tablogger-0.1.7.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

tablogger-0.1.7-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file tablogger-0.1.7.tar.gz.

File metadata

  • Download URL: tablogger-0.1.7.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.4 HTTPX/0.28.1

File hashes

Hashes for tablogger-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9a025e56b0380cffb729dc0c8d3d95c2d2f62abc030acd86db8a55ccbe69694e
MD5 e188bde831ac1de5086f1f4a35310036
BLAKE2b-256 2ebf7faa4340a798f2aa3d30d46c0c544f3255f32c49bace371df1d858cb9a75

See more details on using hashes here.

File details

Details for the file tablogger-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: tablogger-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.4 HTTPX/0.28.1

File hashes

Hashes for tablogger-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8ab00db521cb5b9d5a98ffc29197beba29754bf95f43350c062a15201abd25e0
MD5 fb3d8dbc6ebc795f83534d47eaea1d3f
BLAKE2b-256 24314cd02689231eaa43d7b51512534e098be576520dad912ed0acaf471f4353

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