Python Logger based on BetterStack
Project description
Fewsats Logger
A simple Python logging wrapper for Better Stack (Logtail) with automatic environment context.
5-Minute Setup
-
Install package
pip install fewsats-logger
-
Set environment variables (in .env file or environment)
BETTER_STACK_SOURCE_TOKEN=your_source_token BETTER_STACK_HOST=your_source_host ENV=dev
IMPORTANT: Use dev and prod for ENV values.
Get the host & token by creating a new source at https://telemetry.betterstack.com/
-
Initialize once in your main file
from fewsats_logger.core import setup_logging setup_logging()
-
Use standard logging anywhere in your code
import logging logger = logging.getLogger(__name__) logger.info("Message") logger.error("Error", extra={"order_id": "12345"}) # Add filterable fields
That's it. Logs will appear in Better Stack dashboard and console.
Additional Details
Log Levels
logger.debug(): Detailed debugging informationlogger.info(): Confirmation that things are workinglogger.warning(): Something unexpected happenedlogger.error(): A more serious problemlogger.critical(): A fatal error that prevents operation
Adding Context for Filtering
logger.info("Processing order", extra={
"order_id": "12345",
"customer_id": "67890"
})
Integration Examples
FastAPI
from fastapi import FastAPI
from fewsats_logger import setup_logging
setup_logging()
app = FastAPI()
Flask
from flask import Flask
from fewsats_logger import setup_logging
setup_logging()
app = Flask(__name__)
Command Line
from fewsats_logger import setup_logging
import logging
def main():
setup_logging()
logger = logging.getLogger(__name__)
logger.info("Starting application")
if __name__ == "__main__":
main()
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 fewsats_logger-0.0.3.tar.gz.
File metadata
- Download URL: fewsats_logger-0.0.3.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
703e72e568c0cc01ee19bc2888daf49fa5abd63605bd8f2053bccf54f47b775b
|
|
| MD5 |
f3ae81c61d8815d9117cdaf4ebd33d48
|
|
| BLAKE2b-256 |
e3450ef8243940e700f8326ff33d3f8cf73a7be32eb6b41755075fa610433870
|
File details
Details for the file fewsats_logger-0.0.3-py3-none-any.whl.
File metadata
- Download URL: fewsats_logger-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d4453ed9e6e965b6b10f386955f816e25b93922fc200184b6eae8541dfd3148
|
|
| MD5 |
5d6b2778dfba08f26543d5e09b2cd7fb
|
|
| BLAKE2b-256 |
fe2bd5dc696832c99f8d7832f3209aaf564e04081abc825fe10089f67bcf27c7
|