diff options
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); +} |