feat: implement syslog logging (#181)
* feat: implement syslog logging With this functionality in tree, macOS users could easily access ooniprobe logs by filtering by process name in the console app. Part of https://github.com/ooni/probe/issues/1289 * fix: build on windows * fix: all build issues
This commit is contained in:
parent
cfd3b8f9b2
commit
2381c50dc5
4 changed files with 112 additions and 7 deletions
39
internal/log/handlers/syslog/syslog.c
Normal file
39
internal/log/handlers/syslog/syslog.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef _WIN32
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
void ooniprobe_openlog(void) {
|
||||
#ifndef _WIN32
|
||||
(void)openlog("ooniprobe", LOG_PID, LOG_USER);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ooniprobe_log_debug(const char *message) {
|
||||
#ifndef _WIN32
|
||||
(void)syslog(LOG_DEBUG, "%s", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ooniprobe_log_info(const char *message) {
|
||||
#ifndef _WIN32
|
||||
(void)syslog(LOG_INFO, "%s", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ooniprobe_log_warning(const char *message) {
|
||||
#ifndef _WIN32
|
||||
(void)syslog(LOG_WARNING, "%s", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ooniprobe_log_err(const char *message) {
|
||||
#ifndef _WIN32
|
||||
(void)syslog(LOG_ERR, "%s", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ooniprobe_log_crit(const char *message) {
|
||||
#ifndef _WIN32
|
||||
(void)syslog(LOG_CRIT, "%s", message);
|
||||
#endif
|
||||
}
|
||||
Loading…
Reference in a new issue