Skip to content

Log the time#

The ESP32 can give you the current date and time in the logs of the device. This example illustrates how to check the logs using the Toit console or the CLI.

  time :=
  print "$(%02d time.h):$(%02d time.m)"
  print "$(%04d time.year)-$(%02d time.month)-$(%02d"

The Log tab of your device shows the recent log entries. Uncheck on the "Show system logs" to filter the logs to only display the ones generated by applications. logsconsole

You can also check the Humio tab of the device to see your logs. Get familiar with Humio search query here.

To get any future logs from the CLI, use

toit device logs 

To get logs from yesterday up until 5 minutes ago, use

toit device logs -f 24h -t 5m

To see the recent logs and wait for upcoming ones, use

toit device logs -f 10m