New functions snac_debug() and snac_log().

This commit is contained in:
default 2022-09-19 22:23:33 +02:00
parent 32c188ae8f
commit 1ad66e5166
3 changed files with 16 additions and 0 deletions

1
main.c
View File

@ -14,6 +14,7 @@ int main(int argc, char *argv[])
srv_open("/home/angel/lib/snac/comam.es");
snac_open(&snac, "mike");
snac_log(&snac, xs_str_new("ok"));
return 0;
}

12
snac.c
View File

@ -199,3 +199,15 @@ void snac_free(snac *snac)
free(snac->key);
free(snac->actor);
}
void snac_debug(snac *snac, int level, d_char *str)
/* prints a user debugging information */
{
xs *msg = str;
if (dbglevel >= level) {
xs *tm = xs_local_time("%H:%M:%S");
fprintf(stderr, "%s [%s] %s\n", tm, snac->uid, msg);
}
}

3
snac.h
View File

@ -28,3 +28,6 @@ typedef struct _snac {
int snac_open(snac *snac, char *uid);
void snac_free(snac *snac);
void snac_debug(snac *snac, int level, d_char *str);
#define snac_log(snac, str) snac_debug(snac, 0, str)