mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 06:25:04 +00:00
If ~/error/ exists, also log messages to a file there.
This commit is contained in:
parent
f6b836e120
commit
71855e87e3
1 changed files with 8 additions and 0 deletions
8
snac.c
8
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);
|
||||
|
|
Loading…
Reference in a new issue