diff options
author | sanine <sanine.not@pm.me> | 2022-01-02 17:09:29 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-01-02 17:09:29 -0600 |
commit | 5bc7d084ca129637e4782de5fc0c13be76ad27b8 (patch) | |
tree | 357e032b9f343365b0e8b990eef335c78c67fbe9 /src/logging.c | |
parent | 3c95c890245cbd79c9f31c316e7334a8f9229f04 (diff) |
add README.md and logging
Diffstat (limited to 'src/logging.c')
-rw-r--r-- | src/logging.c | 42 |
1 files changed, 42 insertions, 0 deletions
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 <stdio.h> +#include <stdarg.h> + +#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); + } +} |