Skip to content

Commit

Permalink
src/main: log boot
Browse files Browse the repository at this point in the history
  • Loading branch information
ejoerns committed Aug 17, 2023
1 parent f687de7 commit 59a34fd
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,33 @@ static gboolean status_start(int argc, char **argv)
return TRUE;
}

#define MESSAGE_ID_BOOTED "e60e0add-d345-4cb8-b796-eae0d497af96"

static void r_event_log_booted(const RaucSlot *booted_slot)
{
g_autofree gchar *message = NULL;
GLogField fields[] = {
{"MESSAGE", NULL, -1 },
{"MESSAGE_ID", MESSAGE_ID_BOOTED, -1 },
{"GLIB_DOMAIN", R_EVENT_LOG_DOMAIN, -1},
{"RAUC_EVENT_TYPE", "boot", -1},
{"BOOT_ID", NULL, -1},
{"BUNDLE_HASH", NULL, -1},
};

g_return_if_fail(booted_slot);

message = g_strdup_printf("Booted into %s (%s)", booted_slot->name, booted_slot->bootname);
fields[0].value = message;
fields[4].value = r_context()->boot_id;
if (booted_slot->status && booted_slot->status->bundle_hash) {
fields[5].value = booted_slot->status->bundle_hash;
} else {
fields[5].value = "unknown";
}
g_log_structured_array(G_LOG_LEVEL_INFO, fields, G_N_ELEMENTS(fields));
}

G_GNUC_UNUSED
static void create_run_links(void)
{
Expand Down Expand Up @@ -2051,7 +2078,9 @@ static gboolean service_start(int argc, char **argv)
RaucSlot *booted_slot = r_slot_find_by_device(r_context()->config->slots, r_context()->bootslot);
if (!booted_slot)
booted_slot = r_slot_find_by_bootname(r_context()->config->slots, r_context()->bootslot);
g_message("Booted into %s (%s)", booted_slot->name, booted_slot->bootname);
r_slot_status_load(booted_slot);

r_event_log_booted(booted_slot);

/* update boot ID */
g_free(r_context()->system_status->boot_id);
Expand Down

0 comments on commit 59a34fd

Please sign in to comment.