diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-06-01 19:11:00 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-06-01 19:11:00 +0100 |
commit | c3f421e4046faf8b5f39cd1ad36bc4869405fcc9 (patch) | |
tree | 5d2c8575076a82b6ebe518c91fb14a339e92fe7c /functions.c | |
parent | 0c153207be8a31fc66b7f6e9d0b849357017e34a (diff) |
Put debug logs in subdirectory and have max number to keep be configurable. Also fix possible crash in debugprint() if debug directory doesn't exist yet.
Diffstat (limited to 'functions.c')
-rw-r--r-- | functions.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/functions.c b/functions.c index dbcc54e..cdb594c 100644 --- a/functions.c +++ b/functions.c @@ -80,6 +80,12 @@ void debugprint(int level, char *format, ...) { FILE *fp; int bytes = 0; fp = fopen(debugpath, "a"); + + if (fp == NULL) { + printf("Couldn't open debugpath '%s'!\n", debugpath); + return; + } + if ((bytes = vfprintf(fp, format, args)) < 0) { debugprint(DEBUG_CRIT, "error: could not write to debug file.\n"); } |