Skip to main content

EasyLogger Usage Guide

A simplified Python logging library with colored console output and automatic file logging.

Installation

from easy_logger import EasyLogger

Basic Usage

Simple Logging

from easy_logger import EasyLogger

# Create a logger with default settings
logger = EasyLogger()

# Log messages at different levels
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")

Advanced Configuration

Custom Logger Name and Level

# Create a logger with custom name and log level
logger = EasyLogger(name="my_app", level="DEBUG")

Available log levels:

  • DEBUG - Detailed information for debugging
  • INFO - General informational messages (default)
  • WARNING - Warning messages
  • ERROR - Error messages
  • CRITICAL - Critical error messages

Custom Log Directory

from pathlib import Path

# Use a custom directory for log files
logger = EasyLogger(log_dir=Path("./custom_logs"))

# Or use a string path
logger = EasyLogger(log_dir="./app_logs")

Disable Colored Output

# Disable colored console output
logger = EasyLogger(enable_colors=False)

Combined Configuration

from pathlib import Path

# Combine multiple options
logger = EasyLogger(
    name="my_app",
    level="WARNING",
    log_dir=Path("./app_logs"),
    enable_colors=True
)

Logging Features

String Formatting

# Use % formatting
logger.info("User %s logged in", username)
logger.error("Failed to process %s: %s", filename, error_msg)

# Multiple arguments
logger.debug("Processing item %d of %d", current, total)

Exception Logging

# Log exceptions with traceback
try:
    risky_operation()
except Exception as e:
    logger.error("Operation failed", exc_info=True)

Extra Context

# Add extra context to log messages
logger.info("User action", extra={'user_id': 123, 'action': 'login'})

Features

Automatic Features

  • Colored Console Output: Automatically detects terminal color support

    • DEBUG: Cyan
    • INFO: Green
    • WARNING: Yellow
    • ERROR: Red
    • CRITICAL: Purple
  • File Logging: Automatically saves logs to files

    • Default location: ./logs/YYYYMMDD_log.txt
    • Format: 20260206_log.txt
    • Encoding: UTF-8
  • Dual Output: Logs are written to both console and file simultaneously

Type Safety

The library includes full type hints for better IDE support and type checking:

from easy_logger import EasyLogger
from pathlib import Path

logger: EasyLogger = EasyLogger(
    name="my_app",
    level="INFO",
    log_dir=Path("./logs"),
    enable_colors=True
)

Examples

Web Application Logging

from easy_logger import EasyLogger

logger = EasyLogger(name="web_app", level="INFO")

logger.info("Server started on port 8000")
logger.warning("High memory usage detected: 85%%")
logger.error("Database connection failed", exc_info=True)

Script Logging

from easy_logger import EasyLogger
from pathlib import Path

logger = EasyLogger(
    name="data_processor",
    level="DEBUG",
    log_dir=Path("./script_logs")
)

logger.debug("Starting data processing")
logger.info("Processed %d records", record_count)
logger.warning("Skipped %d invalid records", invalid_count)

Production Logging

from easy_logger import EasyLogger

# Production: WARNING level, no colors for log aggregation
logger = EasyLogger(
    name="production_app",
    level="WARNING",
    enable_colors=False
)

logger.warning("API rate limit approaching")
logger.error("Payment processing failed for order %s", order_id)
logger.critical("Database connection pool exhausted")

Log File Management

Log files are automatically created with the current date:

  • Format: YYYYMMDD_log.txt
  • Example: 20260206_log.txt
  • Location: ./logs/ (or custom directory)

Each day creates a new log file, making it easy to manage and archive logs.

Notes

  • The logger automatically creates the log directory if it doesn't exist
  • Console colors are automatically disabled when output is redirected or piped
  • File logs never contain color codes, only plain text
  • Multiple logger instances can coexist with different configurations

Metadata

Release files for easy-logy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-logy 0.1.0
File Size Uploaded Provenance
easy_logy-0.1.0.tar.gz 6.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-logy 0.1.0
File Interpreter ABI Platform
easy_logy-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / easy_logy-0.1.0.tar.gz

Download URL easy_logy-0.1.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a71b517ac22ed8ef158c55afb1ff45dc1ea3c3fa9734caf3a1e020fc67a0b157
BLAKE2b-256 checksum
How to use checksums
14d84cacf42c4b746d530e4fc9d370b0b0bbf94f30e35622ba178f61cde49dea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / easy_logy-0.1.0-py3-none-any.whl

Download URL easy_logy-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ec0059c3ab2ed48939bfe2ed7e9eb7ee982b4fe3915057892cc625f532d8f60
BLAKE2b-256 checksum
How to use checksums
f20f49c1295716bdbda5040a2bb45fffc52f3f9fe369bc05cb65cc86513a6f77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for easy-logy 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page