Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug log setting #187

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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