Skip to content

Commit 49dfc1d

Browse files
authored
add debug log setting (#187)
* add log setting
1 parent faf8ad1 commit 49dfc1d

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

include/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef struct
3333
uint8_t doAni;
3434
uint8_t update;
3535
uint8_t usb_dev;
36+
uint8_t dbglog;
3637
uint32_t user_id;
3738
uint64_t psid[2];
3839
uint64_t account_id;

source/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ app_config_t apollo_config = {
5757
.doSort = 1,
5858
.doAni = 1,
5959
.update = 1,
60+
.dbglog = 0,
6061
.usb_dev = 9,
6162
.user_id = 0,
6263
.psid = {0, 0},
@@ -615,13 +616,19 @@ s32 main(s32 argc, const char* argv[])
615616
// Load application settings
616617
load_app_settings(&apollo_config);
617618

619+
if (apollo_config.dbglog)
620+
{
621+
dbglogger_init_mode(FILE_LOGGER, APOLLO_PATH "apollo.log", 0);
622+
notify_popup(NOTIFICATION_ICON_DEFAULT, "Debug Logging Enabled\n%s", APOLLO_PATH "apollo.log");
623+
}
624+
618625
// Unpack application data on first run
619626
if (strncmp(apollo_config.app_ver, APOLLO_VERSION, sizeof(apollo_config.app_ver)) != 0)
620627
{
621628
LOG("Unpacking application data...");
622629
// clean_directory(APOLLO_DATA_PATH);
623630
if (extract_zip(APOLLO_APP_PATH "misc/appdata.zip", APOLLO_DATA_PATH))
624-
show_message("Successfully installed local application data");
631+
notify_popup(NOTIFICATION_ICON_DEFAULT, "Successfully installed local application data");
625632

626633
strncpy(apollo_config.app_ver, APOLLO_VERSION, sizeof(apollo_config.app_ver));
627634
save_app_settings(&apollo_config);

source/settings.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ menu_option_t menu_options[] = {
7676
},
7777
{ .name = "\nEnable Debug Log",
7878
.options = NULL,
79-
.type = APP_OPTION_CALL,
80-
.value = NULL,
79+
.type = APP_OPTION_BOOL,
80+
.value = &apollo_config.dbglog,
8181
.callback = log_callback
8282
},
8383
{ .name = NULL }
@@ -218,8 +218,17 @@ void update_callback(int sel)
218218

219219
static void log_callback(int sel)
220220
{
221-
dbglogger_init_mode(FILE_LOGGER, APOLLO_PATH "apollo.log", 1);
222-
show_message("Debug Logging Enabled!\n\n" APOLLO_PATH "apollo.log");
221+
apollo_config.dbglog = !sel;
222+
223+
if (!apollo_config.dbglog)
224+
{
225+
dbglogger_stop();
226+
show_message("Debug Logging Disabled");
227+
return;
228+
}
229+
230+
dbglogger_init_mode(FILE_LOGGER, APOLLO_PATH "apollo.log", 0);
231+
show_message("Debug Logging Enabled\n\n%s", APOLLO_PATH "apollo.log");
223232
}
224233

225234
int save_app_settings(app_config_t* config)

0 commit comments

Comments
 (0)