If a ~/log/ folder exists, also write the log there.

This commit is contained in:
default 2023-06-15 06:15:39 +02:00
parent 9a4ff57205
commit 14b2f69768
3 changed files with 8 additions and 2 deletions

3
data.c
View File

@ -545,6 +545,9 @@ xs_list *index_list_desc(const char *fn, int skip, int show)
xs_str *_object_fn_by_md5(const char *md5) xs_str *_object_fn_by_md5(const char *md5)
{ {
if (!xs_is_hex(md5))
srv_log(xs_fmt("_object_fn_by_md5(): '%s' not hex", md5));
xs *bfn = xs_fmt("%s/object/%c%c", srv_basedir, md5[0], md5[1]); xs *bfn = xs_fmt("%s/object/%c%c", srv_basedir, md5[0], md5[1]);
mkdirx(bfn); mkdirx(bfn);

View File

@ -89,6 +89,8 @@ including HTTP headers. Only useful for debugging. May grow to enormous sizes.
.It Pa error/ .It Pa error/
If this directory exists, HTTP signature check error headers are logged here. If this directory exists, HTTP signature check error headers are logged here.
Only useful for debugging. Only useful for debugging.
.It Pa log/
If this directory exists, log messages are also stored there in daily files.
.It Pa app/ .It Pa app/
This directory stores Mastodon API apps. This directory stores Mastodon API apps.
.It Pa token/ .It Pa token/

5
snac.c
View File

@ -95,8 +95,9 @@ void srv_debug(int level, xs_str *str)
xs *tm = xs_str_localtime(0, "%H:%M:%S"); xs *tm = xs_str_localtime(0, "%H:%M:%S");
fprintf(stderr, "%s %s\n", tm, str); fprintf(stderr, "%s %s\n", tm, str);
/* if the ~/error/ folder exists, also write to a file there */ /* if the ~/log/ folder exists, also write to a file there */
xs *lf = xs_fmt("%s/error/debug.log", srv_basedir); xs *dt = xs_str_localtime(0, "%Y-%m-%d");
xs *lf = xs_fmt("%s/log/%s.log", srv_basedir, dt);
FILE *f; FILE *f;
if ((f = fopen(lf, "a")) != NULL) { if ((f = fopen(lf, "a")) != NULL) {
fprintf(f, "%s %s\n", tm, str); fprintf(f, "%s %s\n", tm, str);