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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fewsats_logger-0.0.2.tar.gz
  • Upload date:
  • Size: 8.3 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.2.tar.gz
Algorithm Hash digest
SHA256 99bd968612e78166883ae72abcf86cd22c9403c6b74fff102c0e71d3f788252e
MD5 2949d5fe30d2a57cf2899c8b20dd0675
BLAKE2b-256 11fabbff5284b6bc33b58576e37f361b0c88f5a6ce58259c3bde7fb8b9982b9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fewsats_logger-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8876e6cffd745ba33453b513c8cdb8e76adfe519256ae19e4d27691afea37852
MD5 35f89264895053b4c8ac88c17b477701
BLAKE2b-256 55bcffed859cf171076b3def512400538114dcce581521ee85216de7eddd7b2f

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