blob: 36109c60e230a3c05cc6e5365c0c37e930110f33 (
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
|
#include "log.h"
const char* log_loglevel_str[5] = {
"---",
"ERROR",
"WARNING",
"NOTE",
"DEBUG"
};
int log_init_file(char* _file, unsigned int _verbosity)
{
int fd = open(_file, O_WRONLY | O_APPEND | O_CREAT | O_DSYNC);
if(fd < 0) {
LOGPRINTF(_LOG_ERROR, "Failed to open LogFile %s", _file);
} else {
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
}
return log_init_stdout(_verbosity);;
}
int log_init_stdout(unsigned int _verbosity)
{
log_loglevel = _verbosity;// > _LOG_DEBUG ? _LOG_DEBUG : _verbosity;
LOGPRINTF(0, "=== RESTART ===");
LOGPRINTF(0, "Verbosity: %i", _verbosity);
return 0;
}
|