From a7a06a7ccfe0af1e134357678b8fa6cf87dff3b0 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Sat, 7 Feb 2009 16:32:56 +0000 Subject: anthy-9100h --- src-diclib/logger.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src-diclib/logger.c (limited to 'src-diclib/logger.c') diff --git a/src-diclib/logger.c b/src-diclib/logger.c new file mode 100644 index 0000000..cdba8d9 --- /dev/null +++ b/src-diclib/logger.c @@ -0,0 +1,48 @@ +/* + * ログの出力 + * $Id: logger.c,v 1.8 2002/05/14 13:24:47 yusuke Exp $ + */ +#include +#include + +#include +#include + +static void (*logger)(int lv, const char *str); +static int current_level = 1; + +void +anthy_do_set_logger(void (*fn)(int lv, const char *str), int lv) +{ + current_level = lv; + logger = fn; + /* to be implemented */ +} + +static void +do_log(int lv, const char *str, va_list arg) +{ + if (lv < current_level) { + return ; + } + fprintf(stderr, "Anthy: "); + vfprintf(stderr, str, arg); +} + +void +anthy_log(int lv, const char *str, ...) +{ + va_list arg; + if (lv > current_level) { + return ; + } + va_start(arg, str); + do_log(lv, str, arg); + va_end(arg); +} + +void +anthy_set_logger(anthy_logger lg, int level) +{ + anthy_do_set_logger(lg, level); +} -- cgit v1.2.1