Metadata-Version: 2.1
Name: neologger
Version: 1.0.0
Summary: NeoLogger is a Python library that wraps logging and notifications for Stomp and Slack in a simple and easy way.
Author-email: Pablo Martinez <neolink3891@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Pablo Martinez
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        1. The above copyright notice and this permission notice shall be included in
           all copies or substantial portions of the Software.
        
        2. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
           IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
           FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
           AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
           LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
           FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
           DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://github.com/neolink3891/NeoLogger
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: stomp.py
Requires-Dist: requests

# NeoLogger

A collection of Python notification classes for enhanced logging, messaging, and Slack notifications.

## Overview

NeoNotifications provides a set of tools to improve logging output with customizable styles, send messages over STOMP protocol, and send Slack notifications with rich formatting.

## Features

- **NeoLogger**: Advanced logging with customizable colors, styles, and templates.
- **StompBabbler**: Send messages over STOMP protocol to a specified queue.
- **SlackNotification**: Assemble and send richly formatted notifications to Slack channels via webhooks.

## Installation

You can install NeoNotifications via pip:

```bash
pip install neologger
```

## Requirements

Python 3.6 or higher

## Dependencies:
stomp.py    
requests

## Usage

### NeoLogger

Basic Usage

```
from neologger import NeoLogger

# Initialize the logger
neologger = NeoLogger("your_script.py")

# Log messages
neologger.log_this("This is a general information message.")
neologger.log_this_warning("This is a warning message.")
neologger.log_this_error("This is an error message.")
```

## Customizing Styles and Templates

```
from neonotifications import NeoLogger, Template

# Initialize the logger
neologger = NeoLogger("your_script.py")

# Set a predefined template
neologger.set_template(Template.DARK)

# Log messages with the new style
neologger.log_this("This message uses the DARK template.")
```

## Measuring Elapsed Time

```
# Get a time mark
start_time = neologger.get_time_mark()

# ... perform some operations ...

# Log with elapsed time
neologger.log_with_elapsed_time("Operation completed.", start_time)
```

## StompBabbler

```
from neonotifications import StompBabbler

# Initialize the babbler
stomp_babbler = StompBabbler(
    user_name="username",
    user_password="password",
    queue="/queue/destination",
    server="stomp.server.com",
    port=61613
)

# Send a message
message = {"key": "value"}
status, response = stomp_babbler.babble(message)

if status:
    print("Message sent successfully.")
else:
    print(f"Failed to send message: {response}")
```

## SlackNotification

```
from neonotifications import SlackNotification
import os

# Initialize the notification
slack_notification = SlackNotification()

# Set the Slack webhook URL (ensure this is stored securely)
slack_notification.set_hook(os.getenv("SLACK_WEBHOOK_URL"))

# Add data fields
slack_notification.add_data("Environment", "Production")
slack_notification.add_data("Status", "Operational")
slack_notification.add_data("Version", "1.0.0")

# Assemble the notification
slack_notification.assemble_notification(
    title="System Status Update",
    summary="All systems are running smoothly.",
    icon="white_check_mark"  # Use Slack emoji code without colons
)

# Send the notification
status, response = slack_notification.send()

if status:
    print("Notification sent successfully.")
else:
    print(f"Failed to send notification: {response}")
```

## Configuration

Environment Variables   
SLACK_WEBHOOK_URL: The webhook URL for sending Slack notifications. It is recommended to store this securely, such as in environment variables or a configuration file not checked into version control.

## Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss changes.

## License

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

## Acknowledgments

Inspired by the need for customizable logging and notification tools in Python applications.

Utilizes the stomp.py library for STOMP protocol messaging.     
Utilizes the requests library for HTTP requests to Slack webhooks.

## Contact

For questions or suggestions, please contact Pablo Martinez at neolink3891@gmail.com.
