Create logs

Usage

Logs are used to report specific events or status modifications such as going from an initialization to a ready state, to report that an initialization has failed, etc.

While logs can be used for debugging purposes, they are not designed as a live console for applications (see application panel).

Log message

A log payload is a format-free json document. You should make sure that you’re organizing your json attributes depending on the requests you plan to do when retrieving the data.

Every log message should be sent with a label identifying the type of log sent. This will improve your query performances and ease-of-use when starting to send different logs.

{
    //Metadata, cloud will add time/device/application details
    ...,

    //Level
    "level": "INFO",

    //Label
    "label": "robot_status",
    
    //Payload
    "payload": {
      //Message
      "message": "Battery is fully charged.",
      //Additional fields
      "charge_duration_ms": 3600000
    }
}

Our API allows to compute aggregation functions (sum, average, etc) and filters (time, application, label, etc) on the fields of the JSON payload to easily query and monitor the state of your applications.

While telemetry can contain any json document, query conditions cannot apply on arrays at the moment, so make sure that you’re not planning requests conditioned by values in arrays.

Send logs

In C++, the API provides the HubClient::sendLog(...) function that can be used from any application.

  //Send simple log
  HubClient::sendLog("Battery is fully charged.", LOG_LEVEL::INFO, "robot_status");
  //Send log with additional fields
  sl_iot::json payload;
  payload["message"] = "Battery is fully charged.";
  payload["charge_duration_ms"] = 3600000;

  HubClient::sendLog(payload, LOG_LEVEL::INFO, "robot_status");

Python provides the same feature with the function HubClient.send_log(...)

Please refer to the following tutorial for further information.