Skip to content

Commit

Permalink
Small fixes for the new logging code
Browse files Browse the repository at this point in the history
  • Loading branch information
crudelios committed Jul 11, 2023
1 parent 02d31f5 commit 5a26c58
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/platform/augustus.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ static void write_log(void *userdata, int category, SDL_LogPriority priority, co

static void backup_log(void)
{
FILE *in = fopen("augustus-log.txt", "rb");
FILE *in = file_open("augustus-log.txt", "rb");
if (!in) {
return;
}
FILE *out = fopen("augustus-log-backup.txt", "wb");
FILE *out = file_open("augustus-log-backup.txt", "wb");
if (!out) {
fclose(in);
return;
Expand All @@ -97,23 +97,25 @@ static void backup_log(void)
}
fwrite(buf, 1, read, out);

fclose(out);
fclose(in);
file_close(out);
file_close(in);
}

static void setup_logging(void)
{
// On some platforms (vita, android), not removing the file will not empty it when reopening for writing
backup_log();

// On some platforms (vita, android), not removing the file will not empty it when reopening for writing
file_remove("augustus-log.txt");
log_file = file_open("augustus-log.txt", "wt");
SDL_LogSetOutputFunction(write_log, NULL);
}

static void teardown_logging(void)
{
log_repeated_messages();

if (log_file) {
log_repeated_messages();
file_close(log_file);
}
}
Expand Down

0 comments on commit 5a26c58

Please sign in to comment.