diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2021-11-07 02:02:45 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2021-11-07 02:02:45 +0300 |
commit | e3a41da5a0a3d70ac53591f2b66144f2be2b3871 (patch) | |
tree | 789cc69b05f2447c11f04dbb6ae972ffa0acd1c9 /src/log.c | |
download | revela-e3a41da5a0a3d70ac53591f2b66144f2be2b3871.tar.gz revela-e3a41da5a0a3d70ac53591f2b66144f2be2b3871.zip |
Initial commit.
Almost functional but still missing features and lacking testing.
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..4ff617f --- /dev/null +++ b/src/log.c @@ -0,0 +1,25 @@ +#include "log.h" + +#include <stdio.h> +#include <stdarg.h> +#include <string.h> +#include <stdbool.h> + +static enum log_level log_verbosity = LOG_INFO; + +void +log_set_verbosity(enum log_level lvl) +{ + log_verbosity = lvl; +} + +void +log_printf(enum log_level lvl, const char *restrict fmt, ...) +{ + if (lvl > log_verbosity) return; + FILE *out = lvl < LOG_INFO ? stderr : stdout; + va_list args; + va_start(args, fmt); + vfprintf(out, fmt, args); + va_end(args); +} |