VCCC  2024.05
VisualCamp Common C++ library
buffer.h
Go to the documentation of this file.
1 # /*
2 # Created by YongGyu Lee on 2021/04/05.
3 # */
4 #
5 # ifndef VCCC_LOG_DETAIL_BUFFER_H_
6 # define VCCC_LOG_DETAIL_BUFFER_H_
7 #
8 # include "boost/predef.h"
9 #
10 # define VCCC_LOG_EXPAND(x) x // defense for MSVC
11 #
12 # if BOOST_PLAT_ANDROID
13 # include <android/log.h>
14 #
15 # define VCCC_LOG_PRINTER(buf, tag, fmt, ...) __android_log_print(buf, tag, fmt, __VA_ARGS__)
16 #
17 # // https://developer.android.com/ndk/reference/group/logging
18 # define VCCC_LOG_BUFFER_DEBUG ANDROID_LOG_DEBUG
19 # define VCCC_LOG_BUFFER_INFO ANDROID_LOG_DEBUG
20 # define VCCC_LOG_BUFFER_WARN ANDROID_LOG_ERROR
21 # define VCCC_LOG_BUFFER_ERROR ANDROID_LOG_ERROR
22 #
23 # elif BOOST_OS_IOS
24 # include "TargetConditionals.h"
25 # include <syslog.h>
26 #
27 # define VCCC_LOG_PRINTER(buf, tag, fmt, ...) syslog(buf, "%s" fmt, tag, __VA_ARGS__)
28 #
29 # // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/syslog.3.html
30 # define VCCC_LOG_BUFFER_DEBUG LOG_DEBUG
31 # define VCCC_LOG_BUFFER_INFO LOG_DEBUG
32 # define VCCC_LOG_BUFFER_WARN LOG_ERR
33 # define VCCC_LOG_BUFFER_ERROR LOG_ERR
34 #
35 # else // for wasm, Windows, MacOS
36 # include <cstdio>
37 #
38 # define VCCC_LOG_PRINTER(buf, tag, fmt, ...) VCCC_LOG_EXPAND(std::fprintf(buf, "%s" fmt "\n", tag, __VA_ARGS__))
39 # define VCCC_LOG_BUFFER_DEBUG stdout
40 # define VCCC_LOG_BUFFER_INFO stdout
41 # define VCCC_LOG_BUFFER_WARN stderr
42 # define VCCC_LOG_BUFFER_ERROR stderr
43 #
44 # endif
45 #
46 # endif //VCCC_LOG_DETAIL_BUFFER_H_