Improved server debug functions.

This commit is contained in:
default 2022-09-19 21:30:19 +02:00
parent 91adc48178
commit b1a1717fd9
2 changed files with 9 additions and 5 deletions

8
snac.c
View file

@ -39,14 +39,16 @@ d_char *xs_time(char *fmt, int local)
}
void srv_log(d_char *str)
/* logs a message */
void srv_debug(int level, d_char *str)
/* logs a debug message */
{
xs *tm = xs_local_time("%H:%M:%S");
xs *msg = str;
if (dbglevel >= level) {
xs *tm = xs_local_time("%H:%M:%S");
fprintf(stderr, "%s %s\n", tm, msg);
}
}
int srv_open(char *basedir)

4
snac.h
View file

@ -11,6 +11,8 @@ d_char *xs_time(char *fmt, int local);
#define xs_local_time(fmt) xs_time(fmt, 1)
#define xs_utc_time(fmt) xs_time(fmt, 0)
void srv_log(d_char *str);
void srv_debug(int level, d_char *str);
#define srv_log(str) srv_debug(0, str)
int srv_open(char *basedir);