Skip to main content

A simple logging library with colored output and file rotation support

Project description

Smpl 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.4.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.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smpl_logger-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 89a6b066d000e00fcd7ca4254875d449d754c665b4b2a357c86aae28036c74ff
MD5 9aaff80426f579d866e59a5f59a17731
BLAKE2b-256 193626422384528959bdaeb3b9f2b38ae55c0de5ab60a253b3a6fdbef9a101a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smpl_logger-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5fa6bceaa8480b31012a5290e3e0b114b384de9c95a6931fd6e630179e4b8be6
MD5 e4df0467b2ed128b36a9e01181ff2ecf
BLAKE2b-256 61cf0483daa098d898a3b1d193e34141c90ff677cd03533fed70372a885c867a

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