Skip to main content

A simple, no-fuss logging setup for Python applications

Project description

Fast Logger

Tests

A simple, no-fuss logging setup for Python applications with sensible defaults.

Features

  • Zero configuration: Works out of the box with sensible defaults
  • Rotating file logs: Automatically manages log file sizes and backups
  • Console output: Simultaneous logging to file and console
  • Flexible configuration: Easy to customize when needed
  • Type hints: Full type hint support for better IDE experience
  • No dependencies: Uses only Python standard library

Installation

pip install python-fast-logger

Quick Start

Super Simple Usage

from fast_logger import quick_logger

logger = quick_logger("my_app")
logger.info("Hello, world!")
logger.error("Something went wrong!")

Basic Usage

from fast_logger import get_logger

logger = get_logger("my_app")
logger.info("Application started")
logger.warning("This is a warning")
logger.error("This is an error")

Advanced Usage

from fast_logger import FastLogger

# Custom configuration
logger = FastLogger(
    name="my_advanced_app",
    level="DEBUG",
    log_folder="custom_logs",
    max_file_size_mb=100,
    backup_count=5,
    console_output=True
)

logger.info("Advanced logging setup complete")
logger.debug("Debug information")

Web Application Example

from fast_logger import get_logger
from flask import Flask

app = Flask(__name__)
logger = get_logger("web_app", level="INFO")

@app.route("/")
def home():
    logger.info("Home page accessed")
    return "Hello, World!"

@app.route("/api/data")
def get_data():
    try:
        # Your API logic here
        data = {"status": "success"}
        logger.info("Data retrieved successfully")
        return data
    except Exception as e:
        logger.error(f"Error retrieving data: {e}")
        return {"status": "error"}, 500

Configuration Options

Parameter Type Default Description
name str Required Logger name (used as filename)
level str/int INFO Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
log_folder str logs Directory name for log files
max_file_size_mb int 50 Maximum size of each log file in MB
backup_count int 3 Number of backup files to keep
console_output bool True Whether to output to console
log_format str Default format Custom log format string
base_path str Caller's directory Base directory for logs

Default Log Format

2024-01-15 10:30:45,123 - my_app [main.py:15] - INFO - Hello, world!

File Structure

By default, logs are created in a logs folder relative to your script:

your_project/
├── main.py
└── logs/
    ├── my_app.log
    ├── my_app.log.1
    └── my_app.log.2

API Reference

FastLogger Class

The main class for advanced usage with full configuration options.

logger = FastLogger(
    name="my_app",
    level="INFO",
    log_folder="logs",
    max_file_size_mb=50,
    backup_count=3,
    console_output=True,
    log_format=None,
    base_path=None
)

Convenience Functions

  • quick_logger(name, level="INFO"): Minimal setup for immediate use
  • get_logger(name, **kwargs): Returns FastLogger instance with fluent interface
  • setup_logger(name, **kwargs): Returns standard logging.Logger instance

Why Fast Logger?

Most Python applications need logging, but setting it up properly requires boilerplate code:

  • Creating formatters
  • Setting up file handlers
  • Configuring rotation
  • Adding console output
  • Managing log directories

Fast Logger eliminates this boilerplate while providing sensible defaults that work for most applications.

Comparison with Standard Logging

Standard logging setup:

import logging
import os
from logging.handlers import RotatingFileHandler

# 15+ lines of boilerplate code...
logger = logging.getLogger("my_app")
logger.setLevel(logging.INFO)
# ... more setup code

Fast Logger:

from fast_logger import quick_logger

logger = quick_logger("my_app")
# Done! 

Requirements

  • Python 3.9+
  • No external dependencies

License

MIT License. See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

See CHANGELOG.md for version history.

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

python_fast_logger-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

python_fast_logger-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file python_fast_logger-0.1.1.tar.gz.

File metadata

  • Download URL: python_fast_logger-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for python_fast_logger-0.1.1.tar.gz
Algorithm Hash digest
SHA256 464e63891d455517e17d80be8d8352be2dba67c83cd7eca9938f26c1d8e504e1
MD5 1224d7d850eab565bba5ca8a6d79bc5b
BLAKE2b-256 830b396be29576a0c88655fd3e061226ac150560ae25195468d100c20028ccae

See more details on using hashes here.

File details

Details for the file python_fast_logger-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_fast_logger-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6235049e75d2a13c1264490836decee275a44799e024049f6c2e78ef258a52df
MD5 82d1ecbf57bed46b15bb11d229b74bed
BLAKE2b-256 31c2be3b02481bc5a8796a503dec452299c200c3be502c3a39a6a83dcaaa7318

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