Skip to main content

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 print function.
  • Sends printed messages to a specified API endpoint.
  • Retains all original print functionality, 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
  • requests library

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:

  1. Fork the repository.
  2. Create a new branch (feature/new-feature).
  3. Commit your changes.
  4. 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


Download files

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

Source Distribution

streamlog-3.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

streamlog-3.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file streamlog-3.0.0.tar.gz.

File metadata

  • Download URL: streamlog-3.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0

File hashes

Hashes for streamlog-3.0.0.tar.gz
Algorithm Hash digest
SHA256 a0942d2f829552569c4f419d0f093c3bdda89bcde36da17cea7d4c54dc8831bf
MD5 abaa2dbfe40b2566c4deff52e95f59d3
BLAKE2b-256 51c0e0c24abd04d79e812d66fc4f471f36694c5aaaf09a87eb429eb1b32c5174

See more details on using hashes here.

File details

Details for the file streamlog-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: streamlog-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0

File hashes

Hashes for streamlog-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a39a400ad06715aab6b565692518749082eb1b16b9f1a8e87c62244d212fdfa0
MD5 a0c12afc07c696c0f38bb0817e7282b6
BLAKE2b-256 5e108836ae2e8d649a482b003024180f842b8275bccac12a6f67eec9bb9204dd

See more details on using hashes here.

Supported by

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