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 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.1.tar.gz (9.0 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.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file fewsats_logger-0.0.1.tar.gz.

File metadata

  • Download URL: fewsats_logger-0.0.1.tar.gz
  • Upload date:
  • Size: 9.0 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.1.tar.gz
Algorithm Hash digest
SHA256 f1ca18b28e4b3700b498dd01f9eac4b50f2de1f78a07f989c5df13a6c02410cd
MD5 1ce4d84b985725f57d575f0ce8da90ef
BLAKE2b-256 9c7347b2cef52cde0f1c93f55bce2d4258de1133a84114016a9900906204c469

See more details on using hashes here.

File details

Details for the file fewsats_logger-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fewsats_logger-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c1abea37941d0a2742e8b27570bd4adfdb7d3e7e1e97402363d7fe5f170f051
MD5 01f36e8c39f21586196e2591aa830d05
BLAKE2b-256 96a7426a72b33f97d84e94d97cb5930062e7ae94df2cc1edfa7339e8f680ff8d

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