Skip to main content

Простая библиотека для логирования с цветным форматированием

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.3.tar.gz (5.3 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.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smpl_logger-0.1.3.tar.gz
  • Upload date:
  • Size: 5.3 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.3.tar.gz
Algorithm Hash digest
SHA256 22b7bade8b88eb2fcc00344ab3d26165c49c882422bcb5b79f690f1020c70d42
MD5 f34c33dfe94eb8b7e2da200a0f9923a7
BLAKE2b-256 1a5bdaccde4b9d8d6bb9fac3cde8316e60ab0372bc82f7e8d5ce26ec1b91f728

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smpl_logger-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 079baf9000d73c069a18b525683e64250f28269f80df0901b8e4fc12ba0f3360
MD5 0a958456084cbb4d5a03b682062bcdff
BLAKE2b-256 007444de081619a6491e19cfb8d51b6ba679446586dfd8cd16213a67f4295a53

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