A Python package to send print statements to an API while printing to the console.
Project description
StreamLog
StreamLog is a Python package that extends the functionality of the print statement by simultaneously sending printed messages to an API. It’s designed to help developers log important information to remote servers while maintaining console output.
Features
- Seamlessly integrates with the standard
printfunction. - Sends printed messages to a specified API endpoint.
- Retains all original
printfunctionality, including custom separators, end characters, and file output.
Installation
Install the package using pip:
pip install StreamLog
Usage
Enable StreamLog
To start using StreamLog, import and enable the custom print functionality by specifying your API endpoint:
from StreamLog import enable_stream_log
# Enable StreamLog with your API endpoint
enable_stream_log(api_url="https://your-api-endpoint.com/logs")
# Use the print function as usual
print("Hello, World!")
Example Output
Console Output:
Hello, World!
API Request:
Endpoint: https://your-api-endpoint.com/logs
Method: POST
Payload:
{
"message": "Hello, World!"
}
Parameters
The enable_stream_log function accepts the following parameter:
api_url(str): The URL of the API endpoint where logs will be sent.
Default:http://example.com/api/logs
Error Handling
If the API call fails (e.g., network issues, invalid endpoint), an error message is displayed in the console, and the print statement continues to function normally.
Example:
StreamLog Error: Failed to send message to API: [Error details]
Requirements
- Python 3.6 or higher
requestslibrary
Installation from Source
Clone the repository and install the package locally:
git clone https://github.com/PrathmeshSoni/StreamLog.git
cd StreamLog
pip install .
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
feature/new-feature). - Commit your changes.
- Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
Developed by Prathmesh Soni
For more details, visit GitHub Repo.
Let me know if you'd like any modifications!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlog-2.1.0.tar.gz.
File metadata
- Download URL: streamlog-2.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e751189f0023c8ed97c9e851c1e37172957e1f02de273dffa3d9d2a152fdd6cf
|
|
| MD5 |
8e49fa4dc30068ebec1e30d03341e978
|
|
| BLAKE2b-256 |
ec97add0b5915d094ce80b03208564503e4e096900e975623f4716ff4ddf4e41
|
File details
Details for the file streamlog-2.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlog-2.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfc9cfe8d993d08ae71ed893886e2c579c43593f2cd5a5f8a5b035ac1f7aa7e3
|
|
| MD5 |
966e2666a1f8e6aedf12393dcb691585
|
|
| BLAKE2b-256 |
218aee1253f0323857ba9def652995401e5812bbc5e3012c54e291263c2f3927
|