Minimal async logger with Telegram transport
Project description
FemtoLogger (Python)
Minimal async logger with Telegram transport for Python.
Install
pip install femtologger
Required env vars
TELEGRAM_BOT_TOKEN=<bot token from @BotFather>
TELEGRAM_CHAT_ID=<chat id from @userinfobot>
Usage
import asyncio
from femtologger import FemtoLogger, TelegramTransport
logger = FemtoLogger(
transports=[
TelegramTransport(
token="your-bot-token",
chat_id="your-chat-id",
),
],
)
async def main():
await logger.info("User signed up", {"userId": 42})
await logger.warn("Rate limit approaching", {"current": 95, "max": 100})
await logger.error("Payment failed", {"orderId": "abc", "reason": "declined"})
asyncio.run(main())
API
FemtoLogger
FemtoLogger(*, transports: list[Transport], level: LogLevel = "info")
| Parameter | Type | Default | Description |
|---|---|---|---|
transports |
list[Transport] |
required | List of transport instances |
level |
"info" | "warn" | "error" |
"info" |
Minimum log level |
Methods: logger.info(message, metadata?), logger.warn(message, metadata?), logger.error(message, metadata?). All are async and return None.
TelegramTransport
TelegramTransport(*, token: str, chat_id: str | int, parse_mode: str = "HTML", disable_web_page_preview: bool = True)
| Parameter | Type | Default |
|---|---|---|
token |
str |
required |
chat_id |
str | int |
required |
parse_mode |
str |
"HTML" |
disable_web_page_preview |
bool |
True |
Custom transport
Implement the Transport protocol:
from femtologger import Transport, LogEntry
class MyTransport:
async def send(self, entry: LogEntry) -> None:
# entry.level: "info" | "warn" | "error"
# entry.message: str
# entry.metadata: dict[str, object] | None
# entry.timestamp: datetime
# IMPORTANT: catch errors internally, never raise
pass
Key behaviors
- Logger never raises at runtime — transport errors are caught and logged to stderr
- Multiple transports are dispatched in parallel via
asyncio.gather(..., return_exceptions=True) - Single runtime dependency (
httpx), requires Python >= 3.10
License
MIT
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 femtologger-0.1.0.tar.gz.
File metadata
- Download URL: femtologger-0.1.0.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b6b9c79162bd86767a5a253ea99bf74039e96e91aaf05508fb4311c444e61e
|
|
| MD5 |
3b378f7fcca4b0b412151de75051a0b7
|
|
| BLAKE2b-256 |
b6424b9c5015a772071276884a178d305b1c637fe374b66cac74f0daf42feca0
|
Provenance
The following attestation bundles were made for femtologger-0.1.0.tar.gz:
Publisher:
ci.yml on frederictriquet/FemtoLogger-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
femtologger-0.1.0.tar.gz -
Subject digest:
c0b6b9c79162bd86767a5a253ea99bf74039e96e91aaf05508fb4311c444e61e - Sigstore transparency entry: 947439435
- Sigstore integration time:
-
Permalink:
frederictriquet/FemtoLogger-python@e8986226e55e3d615b22cc1d580e755beb2f3772 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/frederictriquet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@e8986226e55e3d615b22cc1d580e755beb2f3772 -
Trigger Event:
push
-
Statement type:
File details
Details for the file femtologger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: femtologger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 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 |
3b70cccd2796c797a2c5860ba9ce49020aed0a9e1ba260e4beec91ead0b94b0a
|
|
| MD5 |
53c8842745183c92654b2d28e816a569
|
|
| BLAKE2b-256 |
660b7e715e345803125fc599e976a934b45fef490805efe818fd3c6d59a97cb8
|
Provenance
The following attestation bundles were made for femtologger-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on frederictriquet/FemtoLogger-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
femtologger-0.1.0-py3-none-any.whl -
Subject digest:
3b70cccd2796c797a2c5860ba9ce49020aed0a9e1ba260e4beec91ead0b94b0a - Sigstore transparency entry: 947439438
- Sigstore integration time:
-
Permalink:
frederictriquet/FemtoLogger-python@e8986226e55e3d615b22cc1d580e755beb2f3772 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/frederictriquet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@e8986226e55e3d615b22cc1d580e755beb2f3772 -
Trigger Event:
push
-
Statement type: