Skip to main content

LogStyles

PyPI License Python Versions Tests

🌟 Introduction

LogStyles is a sleek and modern Python library designed to enhance your logging experience with Loguru. It offers a collection of customizable themes and formats that transform your log messages into visually appealing and structured outputs. Whether you're developing a small script or a large-scale application, LogStyles provides the flexibility and aesthetics to make your logs both informative and easy on the eyes.

🚀 Features

  • Multiple Predefined Themes: Choose from a variety of stylish themes like Catpuccin and Tokyo Night.
  • Versatile Log Formats: Utilize different log formats such as Simple, Detailed, Threaded, and Process to suit your needs.
  • Color Customization: Easily customize colors for different log levels and components.
  • Seamless Integration with Loguru: Effortlessly integrate LogStyles into your existing Loguru setup.

📦 Installation

You can install LogStyles using pip:

pip install logstyles

🛠️ Usage

LogStyles is designed to work seamlessly with Loguru. Here's a quick guide to get you started.

📚 Basic Example

import sys
from loguru import logger
from logstyles import LogStyles

def main():
    # Create a formatter with the desired theme and format
    formatter = LogStyles.get_formatter(
        theme_name='Catpuccin Mocha',          # Choose a theme
        format_name='Detailed',      # Choose a format
        delimiter=' | ',             # Optional: Customize delimiter
        timestamp_format='%Y-%m-%d %H:%M:%S'  # Optional: Customize timestamp format
    )
    
    # Configure the logger
    logger.remove()  # Remove the default logger
    logger.add(sys.stdout, format=formatter, colorize=False)  # Add LogStyles formatter
    
    # Log some messages
    logger.debug("Debug message with Mocha theme.")
    logger.info("Info message with Mocha theme.")
    logger.warning("Warning message with Mocha theme.")
    logger.error("Error message with Mocha theme.")
    logger.critical("Critical message with Mocha theme.")

if __name__ == '__main__':
    main()

🎨 Selecting Themes and Formats

LogStyles comes with a variety of themes and formats. Here's how you can explore and use them:

# List of available themes
available_themes = LogStyles.get_available_themes()
print("Available Themes:", available_themes)

# List of available formats
available_formats = LogStyles.get_available_formats()
print("Available Formats:", available_formats)

⚙️ Configuration

🔧 Customizing the Formatter

You can customize the formatter by specifying different parameters:

  • theme_name: The name of the theme you want to use (e.g., 'Catpuccin Latte', 'Tokyo Night Dark').
  • format_name: The name of the log format (e.g., 'Simple', 'Detailed').
  • delimiter: (Optional) A custom delimiter to separate log parts.
  • timestamp_format: (Optional) Customize the timestamp format using strftime directives.

📂 Available Themes and Formats

🎨 Themes

  • Catpuccin Latte
  • Catpuccin Frappe
  • Catpuccin Macchiato
  • Catpuccin Mocha
  • Tokyo Night
  • Tokyo Night Storm
  • Tokyo Night Light

📝 Formats

Format Example
Simple This is a DEBUG message.
Detailed 2024-11-28 15:11:49 | DEBUG | main | main | 39 | This is a DEBUG message.
Threaded 2024-11-28 15:11:49 | DEBUG | MainThread | This is a DEBUG message.
Process 2024-11-28 15:11:49 | DEBUG | MainProcess | This is a DEBUG message.
Left Aligned DEBUG : This is a DEBUG message.
Column 2024-11-28 15:11:49 | DEBUG | main | This is a DEBUG message.

🧪 Testing

LogStyles includes a comprehensive test suite using unittest. To run the tests, navigate to the project directory and execute:

python -m unittest discover tests

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

📬 Contact

For any inquiries or feedback, feel free to reach out:

Metadata

Release files for logstyles 0.1.5

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

Source distribution (sdist)

Source distribution for logstyles 0.1.5
File Size Uploaded
logstyles-0.1.5.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for logstyles 0.1.5
File Interpreter ABI Platform
logstyles-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / logstyles-0.1.5.tar.gz

Download URL logstyles-0.1.5.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
89cc0a4758d65647f0654e0a93a7f826c7c32718395718ab461e9800b4f9eb60
BLAKE2b-256 checksum
How to use checksums
28aee71de1428ca7e98318ec0e0bc22466bc9df4fa0cbec9ea2a261178c5e705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / logstyles-0.1.5-py3-none-any.whl

Download URL logstyles-0.1.5-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdc18947748b7132c257d2607012644f965c968ec6561a94d06fb016a4d03061
BLAKE2b-256 checksum
How to use checksums
82a59f307a261431d913c93d8f24977d0d1c36f0007cf865850b7812d7c6f88a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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