blob: 884492e5cb4a479505d058ceff75c1427e1021e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/* log.c
* (c) Jonas Gunz, 2019
* License: MIT
* */
#include "log.h"
unsigned int log_loglevel;
int log_fd;
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);
}
|