summaryrefslogtreecommitdiff
path: root/src-diclib/logger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src-diclib/logger.c')
-rw-r--r--src-diclib/logger.c48
1 files changed, 48 insertions, 0 deletions
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 <stdio.h>
+#include <stdarg.h>
+
+#include <anthy/anthy.h>
+#include <anthy/logger.h>
+
+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);
+}