Send Logs

Send Logs

POST https://api.upswift.io/v1/send_log_file

Send log files from your devices to the dashboard. You can then view the log files content at the dashboard or download the files. You can send text, as well as binary files. Keep in mind that at the dashboard you can view only the text files. All other files you won't be able to view on the dashboard but only download them.

Request Body

{"message": "Success"}

Restrictions:

  • Max file size: 20Mb

  • Max calls per minute per device: 1

  • Max total files that are being saved on Upswift servers: 30. If you upload a file with a name that already exists, it will be overridden. If you upload more than 30 files in total, the oldest file uploaded will be deleted and replaced by the new file.

Example

import json
import requests


#Upswift tokens
user_token = "<user token>"
device_token = "<device token>"

json_content = {'user_token': user_token,
                'device_token': device_token}


file_name = "log.txt"
file_path = "/home/logs/log.txt"

json_payload = (None, json.dumps(json_content), 'application/json')
file_payload = (file_name, open(file_path, 'rb'), 'application/octet-stream')
final_payload = {'json': json_payload,'file': file_payload}

call_request = requests.post("https://api.upswift.io/v1/send_log_file", files=final_payload)
call_response = json.loads(call_request.text)

if call_request.status_code != 200:
    if call_request.status_code == 429:
        error = "API limit reached"
    else:
        error = call_response["error_message"]
    print(error)
else:
    response_message = call_response["message"]

Last updated