Skip to main content

A logging component with colored output and automated file organization.

Project description

colorpaws

A powerful, flexible logging component that enhances Python's built-in logging with colored output and automated file organization.

Installation

pip install colorpaws

Key Features

  • 🎨 Console Output
    • Colored logging with level-based colors
    • Cross-platform support (Windows/Unix)
    • Smart color detection and handling
  • 📁 File Management
    • Automatic date-based organization
    • Timestamp-based unique files
    • No duplicate handlers
  • ⚙️ Configuration
    • Dual output (console and/or file)
    • Customizable log formats
    • Singleton loggers per name

Usage

Basic Console Logging

from colorpaws import ColorPaws

# Initialize (console only)
logger = ColorPaws(
    name="MyApp",        # Logger instance name
    log_on=True,         # Enable/disable logging
    log_to=None          # No file output
)

# Log messages
logger.debug("Debug information")     # Blue - Detailed debugging
logger.info("Operation complete")     # Green - General information
logger.warning("Low memory")          # Yellow - Potential issues
logger.error("Process failed")        # Red - Serious problems
logger.critical("System crash")       # Magenta - Critical failures

File and Console Logging

# Initialize (console + file)
logger = ColorPaws(
    name="MyApp",        # Logger instance name
    log_on=True,         # Enable/disable logging
    log_to="logs"        # Log directory path
)

# Example with exception handling
try:
    # Your code here
    logger.info("Processing started")
    logger.debug("Loading config...")
    raise ValueError("Invalid input")

except Exception as e:
    logger.error(
        "Process failed",
        exc_info=True    # Include stack trace
    )

Log File Structure

logs/
└── YYYY-MM-DD/
    ├── YYYYMMDD_HHMMSS_MyApp.log
    ├── YYYYMMDD_HHMMSS_MyApp.log
    └── ...

Configuration

Parameters

Parameter Type Default Description
name str Required Logger name
log_on bool False Enable logging
log_to str None Log directory

Log Colors

Level Color Usage
DEBUG Blue Detailed debugging
INFO Green General messages
WARNING Yellow Potential issues
ERROR Red Serious problems
CRITICAL Magenta Critical failures

Log Format

Default: YYYY-MM-DD HH:MM:SS - LEVEL - Message

Best Practices

# Hierarchical naming
logger = ColorPaws("MyApp.SubModule")

# Proper level usage
logger.debug("Detailed debug info")    # Development
logger.info("Operation status")        # General
logger.warning("Potential issue")      # Caution
logger.error("Operation failed")       # Problems
logger.critical("System failure")      # Emergencies

# Exception handling
try:
    # Your code
except Exception as e:
    logger.error("Failed", exc_info=True)

License

See LICENSE for details.

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

colorpaws-25.3.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

colorpaws-25.3.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file colorpaws-25.3.1.tar.gz.

File metadata

  • Download URL: colorpaws-25.3.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for colorpaws-25.3.1.tar.gz
Algorithm Hash digest
SHA256 78bf342176a0cc6f68cd7accc7dbddd534ea9a176425c6e18d43939cc877f4e4
MD5 f74c971e92752a87f61c938fcc909050
BLAKE2b-256 9ceadbf47187e284d301733b45461e2a378ecc6925c9f323ada188317de0903e

See more details on using hashes here.

File details

Details for the file colorpaws-25.3.1-py3-none-any.whl.

File metadata

  • Download URL: colorpaws-25.3.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for colorpaws-25.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bacada6b1f914092a5fb031dd4cb4579a74faba1dd993c3f8fc46236f8c30694
MD5 59865c93b594342de5a3cd64bc6eca00
BLAKE2b-256 48c53865d81f6fd414eb030ed217475ba70d98c85da959d54e0b42477a9d8299

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