generated from Riley/Conan-C
Improve logging initialization: change file opening mode to append and add error handling
This commit is contained in:
parent
03b7afbabf
commit
861c05bc25
1 changed files with 13 additions and 5 deletions
18
src/main.c
18
src/main.c
|
|
@ -16,17 +16,25 @@
|
|||
int main(void) {
|
||||
char *log_path = malloc(256);
|
||||
cwk_path_join(appdata_home_path(), "error.log", log_path, 256);
|
||||
FILE *fp_e = fopen(log_path, "w");
|
||||
log_add_fp(fp_e, LOG_ERROR);
|
||||
FILE *fp_e = fopen(log_path, "a+");
|
||||
if (fp_e) {
|
||||
log_add_fp(fp_e, LOG_ERROR);
|
||||
} else {
|
||||
log_error("Failed to open error log file at %s", log_path);
|
||||
}
|
||||
free(log_path);
|
||||
|
||||
log_path = malloc(256);
|
||||
cwk_path_join(appdata_home_path(), "debug.log", log_path, 256);
|
||||
FILE *fp_d = fopen(log_path, "w");
|
||||
log_add_fp(fp_d, LOG_DEBUG);
|
||||
FILE *fp_d = fopen(log_path, "a+");
|
||||
if (fp_d) {
|
||||
log_add_fp(fp_d, LOG_DEBUG);
|
||||
} else {
|
||||
log_error("Failed to open debug log file at %s", log_path);
|
||||
}
|
||||
free(log_path);
|
||||
|
||||
|
||||
log_debug("Logging initialized.");
|
||||
|
||||
setup_appdata();
|
||||
log_info("Appdata path: %s", appdata_home_path());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue