diff options
| author | 2023-06-11 19:49:56 +0200 | |
|---|---|---|
| committer | 2023-06-11 19:49:56 +0200 | |
| commit | 71855e87e31b257440c56d96b33a936c06912ed0 (patch) | |
| tree | 552e660fccb9bdc7e4e4cc77e3c288d0f6e8ad9f | |
| parent | Fixed comment. (diff) | |
| download | penes-snac2-71855e87e31b257440c56d96b33a936c06912ed0.tar.gz penes-snac2-71855e87e31b257440c56d96b33a936c06912ed0.tar.xz penes-snac2-71855e87e31b257440c56d96b33a936c06912ed0.zip | |
If ~/error/ exists, also log messages to a file there.
Diffstat (limited to '')
| -rw-r--r-- | snac.c | 8 |
1 files changed, 8 insertions, 0 deletions
| @@ -94,6 +94,14 @@ void srv_debug(int level, xs_str *str) | |||
| 94 | if (dbglevel >= level) { | 94 | if (dbglevel >= level) { |
| 95 | xs *tm = xs_str_localtime(0, "%H:%M:%S"); | 95 | xs *tm = xs_str_localtime(0, "%H:%M:%S"); |
| 96 | fprintf(stderr, "%s %s\n", tm, str); | 96 | fprintf(stderr, "%s %s\n", tm, str); |
| 97 | |||
| 98 | /* if the ~/error/ folder exists, also write to a file there */ | ||
| 99 | xs *lf = xs_fmt("%s/error/debug.log", srv_basedir); | ||
| 100 | FILE *f; | ||
| 101 | if ((f = fopen(lf, "a")) != NULL) { | ||
| 102 | fprintf(f, "%s %s\n", tm, str); | ||
| 103 | fclose(f); | ||
| 104 | } | ||
| 97 | } | 105 | } |
| 98 | 106 | ||
| 99 | xs_free(str); | 107 | xs_free(str); |