From 1ad66e5166804bbcc903c63471feb7ea45e2d21a Mon Sep 17 00:00:00 2001 From: default Date: Mon, 19 Sep 2022 22:23:33 +0200 Subject: [PATCH] New functions snac_debug() and snac_log(). --- main.c | 1 + snac.c | 12 ++++++++++++ snac.h | 3 +++ 3 files changed, 16 insertions(+) diff --git a/main.c b/main.c index d047a64..ab4093b 100644 --- a/main.c +++ b/main.c @@ -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; } diff --git a/snac.c b/snac.c index fa84c03..1837766 100644 --- a/snac.c +++ b/snac.c @@ -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); + } +} diff --git a/snac.h b/snac.h index c14fd79..ae98a58 100644 --- a/snac.h +++ b/snac.h @@ -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)