Skip to content

Instantly share code, notes, and snippets.

@jaflo
Last active May 24, 2023 17:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaflo/50c35c46f3ecada7a18c9e5cc203a3f8 to your computer and use it in GitHub Desktop.
Save jaflo/50c35c46f3ecada7a18c9e5cc203a3f8 to your computer and use it in GitHub Desktop.
Flipper Zero stuff

Viewing System Logs

After following these steps you can view messages logged on the OS level. This includes messages logged using FURI_LOG_D (for debug) for example. You can use these in your scripts too:

  • FURI_LOG_E(): error
  • FURI_LOG_W(): warning
  • FURI_LOG_I(): info
  • FURI_LOG_D(): debug
  • FURI_LOG_T(): trace

Steps

Make the following change to cli_command_log in applications/cli/cli_commands.c (and of course make and reflash).

 void cli_command_log(Cli* cli, string_t args, void* context) {
     furi_stdglue_set_global_stdout_callback(cli_stdout_callback);
+    furi_log_set_puts((FuriLogPuts)printf);
     printf("Press any key to stop...\r\n");
     cli_getc(cli);
     furi_stdglue_set_global_stdout_callback(NULL);
+    furi_log_set_puts(furi_hal_console_puts);
 }

Connect to the Flipper using the serial connection and run log to listen for events. You will see output as follows:

grafik

Nothing happening? Try increasing the debug level (Settings > System > Debug Level).

Explanation

The changes patched the log CLI command to direct Furi (OS) to redirect log messages to printf which then get sent to the console. The second lines undoes the change once the log invocation ends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment