log()

log(title, [description], [type], [priority], [value])

Writes a message to the persistent system event log — short form with a severity, or extended form with grouping, priority and an attached value.

Unlike print() (console output), log() writes to the internal device event log.

If cloud synchronisation is enabled, the event log is automatically uploaded to the cloud.

The log entries are stored in RAM and therefore have an unlimited write endurance but will also be lost if power to the device is not maintained.

Two forms are supported:

Short form — a message plus a severity constant:

log("Logic Started", alm.info);

Extended form — title, description, a numeric type for grouping, a priority, and a numeric value attached to the message. This structured form is particularly useful when the device reports to a Grafana / InfluxDB cloud backend, where the fields become queryable:

log(
  "Title",
  "Description / Message",
  3,     // type, 0–255 — used for grouping alarm/message types
  2,     // priority, 0–255 — user definable, or use alm.ok / alm.info / alm.warn / alm.crit
  23.43  // alarm value — numeric value attached to the message
);

Arguments

NameTypeRequiredDefaultDescription
title string yes Title of the log entry (or the whole message in short form).
description string optional Longer description / message body.
type number optional 0 Message type, 0–255. Used for grouping alarm/message types.
priority number | alm constant yes Priority 0–255 — user definable, or one of alm.ok, alm.info, alm.warn, alm.crit.
value number optional NAN Numeric value attached to the entry (e.g. the measurement that triggered it).

Example

// Short form
log("Logic Started", alm.info); 

// Extended form
log("Pump Fault", "Discharge pressure out of range", 3, alm.warn, 23.43);