summaryrefslogtreecommitdiff
path: root/snac.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-06-11 19:49:56 +0200
committerdefault <nobody@localhost>2023-06-11 19:49:56 +0200
commit71855e87e31b257440c56d96b33a936c06912ed0 (patch)
tree552e660fccb9bdc7e4e4cc77e3c288d0f6e8ad9f /snac.c
parentf6b836e120408c9a6d2791fc932aea3c081d1654 (diff)
If ~/error/ exists, also log messages to a file there.
Diffstat (limited to 'snac.c')
-rw-r--r--snac.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/snac.c b/snac.c
index 691c2e2..41e1984 100644
--- a/snac.c
+++ b/snac.c
@@ -94,6 +94,14 @@ void srv_debug(int level, xs_str *str)
if (dbglevel >= level) {
xs *tm = xs_str_localtime(0, "%H:%M:%S");
fprintf(stderr, "%s %s\n", tm, str);
+
+ /* if the ~/error/ folder exists, also write to a file there */
+ xs *lf = xs_fmt("%s/error/debug.log", srv_basedir);
+ FILE *f;
+ if ((f = fopen(lf, "a")) != NULL) {
+ fprintf(f, "%s %s\n", tm, str);
+ fclose(f);
+ }
}
xs_free(str);