1 /* SPDX-License-Identifier: GPL-3.0-or-later
2  * Copyright © 2016-2018 The TokTok team.
3  * Copyright © 2015-2016 Tox project.
4  */
5 
6 /*
7  * Tox DHT bootstrap daemon.
8  * Logging utility with support of multiple logging backends.
9  */
10 #ifndef C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_H
11 #define C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_H
12 
13 #include <stdbool.h>
14 
15 #include "../../../toxcore/ccompat.h"
16 
17 typedef enum LOG_BACKEND {
18     LOG_BACKEND_STDOUT,
19     LOG_BACKEND_SYSLOG
20 } LOG_BACKEND;
21 
22 typedef enum LOG_LEVEL {
23     LOG_LEVEL_INFO,
24     LOG_LEVEL_WARNING,
25     LOG_LEVEL_ERROR
26 } LOG_LEVEL;
27 
28 /**
29  * Initializes logger.
30  * @param backend Specifies which backend to use.
31  * @return true on success, false if log is already opened.
32  */
33 bool log_open(LOG_BACKEND backend);
34 
35 /**
36  * Releases all used resources by the logger.
37  * @return true on success, false if log is already closed.
38  */
39 bool log_close(void);
40 
41 /**
42  * Writes a message to the log.
43  * @param level Log level to use.
44  * @param format printf-like format string.
45  * @param ... Zero or more arguments, similar to printf function.
46  * @return true on success, false if log is closed.
47  */
48 bool log_write(LOG_LEVEL level, const char *format, ...) GNU_PRINTF(2, 3);
49 
50 
51 #endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_H
52