Skip to content

Commit

Permalink
add debug log setting (#187)
Browse files Browse the repository at this point in the history
* add log setting
  • Loading branch information
bucanero authored Nov 2, 2024
1 parent faf8ad1 commit 49dfc1d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef struct
uint8_t doAni;
uint8_t update;
uint8_t usb_dev;
uint8_t dbglog;
uint32_t user_id;
uint64_t psid[2];
uint64_t account_id;
Expand Down
9 changes: 8 additions & 1 deletion source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ app_config_t apollo_config = {
.doSort = 1,
.doAni = 1,
.update = 1,
.dbglog = 0,
.usb_dev = 9,
.user_id = 0,
.psid = {0, 0},
Expand Down Expand Up @@ -615,13 +616,19 @@ s32 main(s32 argc, const char* argv[])
// Load application settings
load_app_settings(&apollo_config);

if (apollo_config.dbglog)
{
dbglogger_init_mode(FILE_LOGGER, APOLLO_PATH "apollo.log", 0);
notify_popup(NOTIFICATION_ICON_DEFAULT, "Debug Logging Enabled\n%s", APOLLO_PATH "apollo.log");
}

// Unpack application data on first run
if (strncmp(apollo_config.app_ver, APOLLO_VERSION, sizeof(apollo_config.app_ver)) != 0)
{
LOG("Unpacking application data...");
// clean_directory(APOLLO_DATA_PATH);
if (extract_zip(APOLLO_APP_PATH "misc/appdata.zip", APOLLO_DATA_PATH))
show_message("Successfully installed local application data");
notify_popup(NOTIFICATION_ICON_DEFAULT, "Successfully installed local application data");

strncpy(apollo_config.app_ver, APOLLO_VERSION, sizeof(apollo_config.app_ver));
save_app_settings(&apollo_config);
Expand Down
17 changes: 13 additions & 4 deletions source/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ menu_option_t menu_options[] = {
},
{ .name = "\nEnable Debug Log",
.options = NULL,
.type = APP_OPTION_CALL,
.value = NULL,
.type = APP_OPTION_BOOL,
.value = &apollo_config.dbglog,
.callback = log_callback
},
{ .name = NULL }
Expand Down Expand Up @@ -218,8 +218,17 @@ void update_callback(int sel)

static void log_callback(int sel)
{
dbglogger_init_mode(FILE_LOGGER, APOLLO_PATH "apollo.log", 1);
show_message("Debug Logging Enabled!\n\n" APOLLO_PATH "apollo.log");
apollo_config.dbglog = !sel;

if (!apollo_config.dbglog)
{
dbglogger_stop();
show_message("Debug Logging Disabled");
return;
}

dbglogger_init_mode(FILE_LOGGER, APOLLO_PATH "apollo.log", 0);
show_message("Debug Logging Enabled\n\n%s", APOLLO_PATH "apollo.log");
}

int save_app_settings(app_config_t* config)
Expand Down

0 comments on commit 49dfc1d

Please sign in to comment.