Replace long paths with ~ in logs.

This commit is contained in:
default 2022-09-24 10:18:34 +02:00
parent d69fa8d855
commit e9c2f58993

12
snac.c
View file

@ -60,6 +60,12 @@ void srv_debug(int level, d_char *str)
{ {
xs *msg = str; xs *msg = str;
if (xs_str_in(str, srv_basedir) != -1) {
/* replace basedir with ~ */
xs *o_str = str;
str = xs_replace(o_str, srv_basedir, "~");
}
if (dbglevel >= level) { if (dbglevel >= level) {
xs *tm = xs_local_time("%H:%M:%S"); xs *tm = xs_local_time("%H:%M:%S");
fprintf(stderr, "%s %s\n", tm, msg); fprintf(stderr, "%s %s\n", tm, msg);
@ -87,6 +93,12 @@ void snac_debug(snac *snac, int level, d_char *str)
xs *o_str = str; xs *o_str = str;
d_char *n_str = xs_fmt("[%s] %s", snac->uid, o_str); d_char *n_str = xs_fmt("[%s] %s", snac->uid, o_str);
if (xs_str_in(n_str, snac->basedir) != -1) {
/* replace long basedir references with ~ */
xs *o_str = n_str;
n_str = xs_replace(o_str, snac->basedir, "~");
}
srv_debug(level, n_str); srv_debug(level, n_str);
} }