commit 71855e8
default
·
2023-06-11 17:49:56 +0000 UTC
parent f6b836e
If ~/error/ exists, also log messages to a file there.
1 files changed,
+8,
-0
M
snac.c
M
snac.c
+8,
-0
1@@ -94,6 +94,14 @@ void srv_debug(int level, xs_str *str)
2 if (dbglevel >= level) {
3 xs *tm = xs_str_localtime(0, "%H:%M:%S");
4 fprintf(stderr, "%s %s\n", tm, str);
5+
6+ /* if the ~/error/ folder exists, also write to a file there */
7+ xs *lf = xs_fmt("%s/error/debug.log", srv_basedir);
8+ FILE *f;
9+ if ((f = fopen(lf, "a")) != NULL) {
10+ fprintf(f, "%s %s\n", tm, str);
11+ fclose(f);
12+ }
13 }
14
15 xs_free(str);