Push notifications from your Python Code - Blog - LogHive Smart Event und Log Ta

Push notifications from your Python Code

As developers, we all know how crucial it is to track errors and events in our applications. Without proper logging, it can be difficult to identify issues and fix them before they become major problems. However, managing logs and constantly checking dashboards can be a tedious and time-consuming task.

In the past, I used to log errors and events to files or send them to myself via email. But as my projects grew, it became overwhelming and difficult to manage. That’s why I started looking for a better solution.

That’s when I came to the idea for buiding LogHive, an event service that simplifies logging and tracking events. With LogHive, you can receive push notifications directly to your mobile device whenever an event is triggered. This allows you to stay on top of your application’s performance and quickly identify and address any issues that arise.

How it works

LogHive provides a simple REST API that you can use to push events and errors to the LogHive service. You can organize your events into projects and groups to keep them organized and easily searchable. Once an event is pushed to LogHive, it is processed and can be viewed in the event stream or dashboard.

With just a few lines of code, you can start pushing events to LogHive and receiving push notifications for your application’s events and errors.

import requests
import json

url = "https://api.loghive.app/v1/event/add"
headers = {'Content-Type': 'application/json', 'ApiKey': 'YourPersonalApiKey'}
data = { "projectName": "yourprojectname","groupName": "yourgroupname","eventName": "your-event-name", "description": "your-description", "notify": False }
response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.status_code)
print(response.json())

If an error occurs while creating an event, you will receive an Error object in return.

{'StatusCode': 400, 'Message': 'missing group name'}

You can receive your API-Key here: API-Key.

Receive Push Notifications

To receive push notifications, you simply need to install the LogHive Android app (Playstore) or use LogHive through the web application and allow notifications.

Add an element to your project dashboard

In addition to push notifications, LogHive allows you to display captured events in a dashboard with various elements. With just a few clicks, you can display the events already pushed in the dashboard.

In conclusion, logging and tracking events is essential for maintaining a healthy and performant application. However, it doesn’t have to be a tedious and overwhelming task. With LogHive, you can simplify the process and stay on top of your application’s performance with ease

Latest Posts