src/server/config/logging.c

Tue, 12 Sep 2023 18:08:11 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 12 Sep 2023 18:08:11 +0200
changeset 511
a5a142fea2ae
parent 453
4586d534f9b5
permissions
-rw-r--r--

update uwproj

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