Skip to content

LogStyles is a powerful PyPI module that provides customizable themes and formats for Python loggers like Loguru. Enhance your logging experience popular color schemes, multiple layout styles (e.g., Column, LeftAligned), and configurable log components to suit your project's needs.

License

Notifications You must be signed in to change notification settings

jaylann/LogStyles

Repository files navigation

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:


Made with ❤️ by Justin Lanfermann

About

LogStyles is a powerful PyPI module that provides customizable themes and formats for Python loggers like Loguru. Enhance your logging experience popular color schemes, multiple layout styles (e.g., Column, LeftAligned), and configurable log components to suit your project's needs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages