From 5bc7d084ca129637e4782de5fc0c13be76ad27b8 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 2 Jan 2022 17:09:29 -0600 Subject: add README.md and logging --- src/logging.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/logging.c (limited to 'src/logging.c') diff --git a/src/logging.c b/src/logging.c new file mode 100644 index 0000000..0481908 --- /dev/null +++ b/src/logging.c @@ -0,0 +1,42 @@ +#include +#include + +#include "logging.h" + +int argent_log_level; + +const char *level_string(int level) +{ + switch(level) { + case FATAL: + return "FATAL"; + case ERROR: + return "ERROR"; + case WARN: + return "WARN"; + case INFO: + return "INFO"; + case DEBUG: + return "DEBUG"; + case TRACE: + return "TRACE"; + + default: + if (level > TRACE) + return "TRACE"; + return "[BAD LOG LEVEL]"; + } +} + + +void argent_log(int level, const char *format_string, ...) +{ + if (argent_log_level >= level) { + va_list args; + va_start(args, format_string); + fprintf(stderr, "[%s] ", level_string(level)); + vfprintf(stderr, format_string, args); + fprintf(stderr, "\n"); + va_end(args); + } +} -- cgit v1.2.1