Skip to main content

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

  1. Install package

    pip install fewsats-logger
    
  2. 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/

  1. Initialize once in your main file

     from fewsats_logger.core import setup_logging
    setup_logging()
    
  2. 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 information
  • logger.info(): Confirmation that things are working
  • logger.warning(): Something unexpected happened
  • logger.error(): A more serious problem
  • logger.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fewsats_logger-0.0.3.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

fewsats_logger-0.0.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

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

Hashes for fewsats_logger-0.0.3.tar.gz
Algorithm Hash digest
SHA256 703e72e568c0cc01ee19bc2888daf49fa5abd63605bd8f2053bccf54f47b775b
MD5 f3ae81c61d8815d9117cdaf4ebd33d48
BLAKE2b-256 e3450ef8243940e700f8326ff33d3f8cf73a7be32eb6b41755075fa610433870

See more details on using hashes here.

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

Hashes for fewsats_logger-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7d4453ed9e6e965b6b10f386955f816e25b93922fc200184b6eae8541dfd3148
MD5 5d6b2778dfba08f26543d5e09b2cd7fb
BLAKE2b-256 fe2bd5dc696832c99f8d7832f3209aaf564e04081abc825fe10089f67bcf27c7

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