summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/functions.c b/functions.c
index 4ea5a51..c23366d 100644
--- a/functions.c
+++ b/functions.c
@@ -103,8 +103,21 @@ void debugprint(int level, char *format, ...) {
return;
}
+ // Prepend a timestamp to each line
+ time_t rawtime;
+ struct tm * timeinfo;
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ // Strip the trailing newline
+ char timestr[MAXCHAR];
+ snprintf(timestr, MAXCHAR, "%s", asctime(timeinfo));
+ timestr[strlen(timestr) - 1] = '\0';
+ if ((bytes = fprintf(fp, "%s: ", timestr)) < 0) {
+ debugprint(DEBUG_CRIT, "error: could not write timestamp to debug file.\n"); // TODO - This might not be useful if we can't write
+ }
+
if ((bytes = vfprintf(fp, format, args)) < 0) {
- debugprint(DEBUG_CRIT, "error: could not write to debug file.\n");
+ debugprint(DEBUG_CRIT, "error: could not write to debug file.\n"); // TODO - This might not be useful if we can't write
}
fclose(fp);