summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/src/log_backend_stdout.c
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2017-03-02 02:38:57 -0500
committerMaxim Biro <nurupo.contributions@gmail.com>2017-06-04 16:07:03 -0400
commitb0aec02225b642b2e420e634dce919beee0cd0f2 (patch)
treedf290f8e2f76efda437f1455411f576b3f9f7766 /other/bootstrap_daemon/src/log_backend_stdout.c
parent1e8fa85aadf602bdca3a540de09a8184f7139a6c (diff)
Split daemon's logging backends in separate modules
Diffstat (limited to 'other/bootstrap_daemon/src/log_backend_stdout.c')
-rw-r--r--other/bootstrap_daemon/src/log_backend_stdout.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/other/bootstrap_daemon/src/log_backend_stdout.c b/other/bootstrap_daemon/src/log_backend_stdout.c
new file mode 100644
index 00000000..9a3573c7
--- /dev/null
+++ b/other/bootstrap_daemon/src/log_backend_stdout.c
@@ -0,0 +1,47 @@
1/*
2 * Tox DHT bootstrap daemon.
3 * Stdout logging backend.
4 */
5
6/*
7 * Copyright © 2016-2017 The TokTok team.
8 * Copyright © 2015-2016 Tox project.
9 *
10 * This file is part of Tox, the free peer to peer instant messenger.
11 *
12 * Tox is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * Tox is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
24 */
25#include "log_backend_stdout.h"
26
27#include <stdio.h>
28
29static FILE *log_backend_stdout_level(LOG_LEVEL level)
30{
31 switch (level) {
32 case LOG_LEVEL_INFO:
33 return stdout;
34
35 case LOG_LEVEL_WARNING: // intentional fallthrough
36 case LOG_LEVEL_ERROR:
37 return stderr;
38 }
39
40 return stdout;
41}
42
43void log_backend_stdout_write(LOG_LEVEL level, const char *format, va_list args)
44{
45 vfprintf(log_backend_stdout_level(level), format, args);
46 fflush(log_backend_stdout_level(level));
47}