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:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logstyles-0.1.5.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

logstyles-0.1.5-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file logstyles-0.1.5.tar.gz.

File metadata

  • Download URL: logstyles-0.1.5.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for logstyles-0.1.5.tar.gz
Algorithm Hash digest
SHA256 89cc0a4758d65647f0654e0a93a7f826c7c32718395718ab461e9800b4f9eb60
MD5 bb2ae5ab1cc3ef8305425b77e789334b
BLAKE2b-256 28aee71de1428ca7e98318ec0e0bc22466bc9df4fa0cbec9ea2a261178c5e705

See more details on using hashes here.

File details

Details for the file logstyles-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: logstyles-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for logstyles-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc18947748b7132c257d2607012644f965c968ec6561a94d06fb016a4d03061
MD5 f3c487642434dba3e579662694f35aa9
BLAKE2b-256 82a59f307a261431d913c93d8f24977d0d1c36f0007cf865850b7812d7c6f88a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page