summaryrefslogtreecommitdiff
path: root/src/logging/logging.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2021-09-24 22:45:39 -0500
committersanine <sanine.not@pm.me>2021-09-24 22:45:39 -0500
commit78e262b448e034e96aa75193a76d36cd0062daf7 (patch)
tree52aadee7d06727b762cf9d9a2defc1136e8ddbd3 /src/logging/logging.c
parent92fe2dc01578533a7ecd506ada134b471380a90a (diff)
add getters and setters for log level/file
Diffstat (limited to 'src/logging/logging.c')
-rw-r--r--src/logging/logging.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/logging/logging.c b/src/logging/logging.c
index 77c648c..82895d4 100644
--- a/src/logging/logging.c
+++ b/src/logging/logging.c
@@ -37,13 +37,42 @@ const char * honey_log_level_str()
}
-void honey_debug(const char *fmt, ...)
+void honey_log_set_level(enum honey_log_level_t level)
{
- if (honey_log_info.log_level >= DEBUG) {
+ honey_log_info.log_level = level;
+}
+
+
+enum honey_log_level_t honey_log_get_level()
+{
+ return honey_log_info.log_level;
+}
+
+
+void honey_log_set_file(FILE* file)
+{
+ honey_log_info.log_file = file;
+}
+
+
+FILE * honey_log_get_file()
+{
+ return honey_log_info.log_file;
+}
+
+
+void honey_log(enum honey_log_level_t required_level,
+ const char *prefix,
+ const char *fmt, ...)
+{
+ if (honey_log_info.log_file == NULL)
+ return;
+
+ if (honey_log_info.log_level >= required_level) {
va_list args;
va_start(args, fmt);
- fprintf(honey_log_info.debug_out, "[DEBUG] ");
- vfprintf(honey_log_info.debug_out, fmt, args);
+ fprintf(honey_log_info.log_file, prefix);
+ vfprintf(honey_log_info.log_file, fmt, args);
va_end(args);
}
}