src/server/config/logging.c

Wed, 27 Nov 2024 23:00:07 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 27 Nov 2024 23:00:07 +0100
changeset 563
6ca97c99173e
parent 453
4586d534f9b5
permissions
-rw-r--r--

add TODO to use a future ucx feature

453
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 //
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 // Created by Olaf Wintermann on 23.02.23.
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 //
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 #include "logging.h"
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 #include <stdio.h>
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 int default_log_func(int degree, const char *format, va_list args) {
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 vprintf(format, args);
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 return 0;
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 }
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 static cfg_logfunc logfunc = default_log_func;
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 int ws_cfg_log(int degree, const char *format, ...) {
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 va_list args;
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 va_start(args, format);
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 int ret = logfunc(degree, format, args);
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 va_end(args);
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 return ret;
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 }
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 void ws_cfg_set_logfunc(cfg_logfunc func) {
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 logfunc = func;
4586d534f9b5 fix build on macos
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 }

mercurial