summaryrefslogtreecommitdiff
path: root/src/logging
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2021-09-24 00:04:34 -0500
committersanine <sanine.not@pm.me>2021-09-24 00:04:34 -0500
commit92fe2dc01578533a7ecd506ada134b471380a90a (patch)
treef4abc20d0ed92d3bc248f5068d82106d9ef2f99d /src/logging
parent921f1a46bbccbdf9dcadbd7017ec0c575d2bed1f (diff)
update logging to use real functions
Diffstat (limited to 'src/logging')
-rw-r--r--src/logging/logging.c20
-rw-r--r--src/logging/logging.h18
2 files changed, 26 insertions, 12 deletions
diff --git a/src/logging/logging.c b/src/logging/logging.c
index 429f222..77c648c 100644
--- a/src/logging/logging.c
+++ b/src/logging/logging.c
@@ -1,11 +1,15 @@
#include <stdio.h>
+#include <stdarg.h>
#include "logging/logging.h"
-const char * honey_log_level_str_(struct honey_log_info *info)
+struct honey_log_info_t honey_log_info;
+
+
+const char * honey_log_level_str()
{
- switch(info->log_level) {
+ switch(honey_log_info.log_level) {
case DEBUG:
return "DEBUG";
break;
@@ -31,3 +35,15 @@ const char * honey_log_level_str_(struct honey_log_info *info)
break;
}
}
+
+
+void honey_debug(const char *fmt, ...)
+{
+ if (honey_log_info.log_level >= DEBUG) {
+ va_list args;
+ va_start(args, fmt);
+ fprintf(honey_log_info.debug_out, "[DEBUG] ");
+ vfprintf(honey_log_info.debug_out, fmt, args);
+ va_end(args);
+ }
+}
diff --git a/src/logging/logging.h b/src/logging/logging.h
index 8f4d174..69ea88e 100644
--- a/src/logging/logging.h
+++ b/src/logging/logging.h
@@ -4,7 +4,7 @@
#include <stdio.h>
-struct honey_log_info {
+struct honey_log_info_t {
enum { FATAL, ERROR, WARN, INFO, DEBUG } log_level;
FILE *debug_out;
FILE *info_out;
@@ -13,16 +13,14 @@ struct honey_log_info {
FILE *fatal_out;
};
-const char * honey_log_level_str_(struct honey_log_info *info);
+extern struct honey_log_info_t honey_log_info;
-#define honey_log_(info, required_level, prefix, ...) do { \
- if (info.log_level >= required_level) { \
- fprintf(info.debug_out, prefix " " __VA_ARGS__); \
- } \
- } while(0)
+const char * honey_log_level_str();
-#define honey_debug_(info, ...) \
- honey_log_(info, DEBUG, "[DEBUG]", __VA_ARGS__)
-
+void honey_debug(const char *fmt, ...);
+void honey_info(const char *fmt, ...);
+void honey_warn(const char *fmt, ...);
+void honey_error(const char *fmt, ...);
+void honey_fatal(const char *fmt, ...);
#endif