Skip to main content

A simple logging library with colored output and file rotation support

Project description

SiMPLe Logger

A simple logging library with colored output and file rotation support

Installation

pip install smpl-logger

Or install from source:

pip install git+https://github.com/greengoblinalex/simple-logger.git

Usage

from smpl_logger import get_logger

# It is recommended to use __name__ as the logger name —
# this is convenient for structuring logs in large projects
logger = get_logger(__name__)

# You can also explicitly pass a string, for example:
# logger = get_logger("my_app")
logger.info("This is an info message")
logger.error("This is an error message")

# Logging to file and console
file_logger = get_logger(__name__, log_file="app.log")
file_logger.info("This message will appear in both file and console")

Configuration

You can configure the logger using additional parameters:

logger = get_logger(
    name=__name__,  # Recommended to use __name__, but you can use a string
    log_file="app.log",
    level="DEBUG",  # Logging level
    rotation_size=5 * 1024 * 1024,  # 5 MB for rotation
    backup_count=3  # Keep 3 backup files
)

Configuration via .env file

You can also configure logging parameters via a .env file in your project root:

LOG_DIR=logs                # Directory for log files
LOG_LEVEL=INFO              # Logging level
LOG_ROTATION_SIZE=5242880   # File size for rotation (5MB)
LOG_BACKUP_COUNT=3          # Number of backup files

Features

  • 🎨 Colored output - different log levels are highlighted with different colors
  • 🔄 File rotation - automatic log rotation when the file reaches the maximum size
  • ⚙️ Flexible configuration - configure via function parameters or environment variables
  • 📦 Lightweight - no external dependencies, uses only the Python standard library
  • 🔧 Easy to use - minimal code to get started

Example of colored output

When using console logging, you will see:

  • 🟢 INFO - green for informational messages
  • 🟡 WARNING - yellow for warnings
  • 🔴 ERROR - red for errors
  • 🔵 DEBUG - cyan for debug information
  • 🟥 CRITICAL - red background for critical errors

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

smpl_logger-0.1.5.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

smpl_logger-0.1.5-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file smpl_logger-0.1.5.tar.gz.

File metadata

  • Download URL: smpl_logger-0.1.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for smpl_logger-0.1.5.tar.gz
Algorithm Hash digest
SHA256 eeed9fb0939243fb2166b7d213db62ce1680960e72bfbe622cf3fef35f431367
MD5 6ad3d9b3db0ee3ef877d6f0712a88161
BLAKE2b-256 fbdc2d4154be5b0bd7d7d5de9075b7984f1d2139871e25655132712340e9920a

See more details on using hashes here.

File details

Details for the file smpl_logger-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: smpl_logger-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for smpl_logger-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1792e9b974ac024c7f53da3c202b0a4783fac7785c716c057943fcd64d63053b
MD5 998a94483c2951b42609cd31bac86fc4
BLAKE2b-256 8701b4805c7144b693ca7b4b91bbda47f88e7a5a65e2f071abd2988bb8a51630

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