diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2019-11-29 23:54:01 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2019-11-29 23:54:01 +0100 |
commit | 9a8214e0304a1dffe0a321d96d01045cfc34c8e8 (patch) | |
tree | 3a92b0f6de06290f6471eb30821faef6ea14bed6 /src/log.c | |
parent | 73ede020c76126e81325fcd8d3e186132db21198 (diff) | |
download | dns-9a8214e0304a1dffe0a321d96d01045cfc34c8e8.tar.gz |
asdf
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..197582c --- /dev/null +++ b/src/log.c @@ -0,0 +1,32 @@ +#include "log.h" + +const char* log_loglevel_str[5] = { + "---", + "ERROR", + "WARNING", + "NOTE", + "DEBUG" +}; + +int log_init_file(char* _file, unsigned int _verbosity) +{ + log_fd = open(_file, O_WRONLY | O_APPEND | O_CREAT | O_DSYNC); + + return log_init_stdout(_verbosity);; +} + +int log_init_stdout(unsigned int _verbosity) +{ + log_loglevel = _verbosity;// > _LOG_DEBUG ? _LOG_DEBUG : _verbosity; + log_fd = STDIN_FILENO; + + LOGPRINTF(0, "=== RESTART ==="); + LOGPRINTF(0, "Verbosity: %i", _verbosity); + + return 0; +} + +int log_close() +{ + return close(log_fd); +} |