2fc1f15e91097dbeef766f6b9a9fd26313261360
[iec.git] / src / type3_AndroidCloud / anbox-master / external / android-emugl / shared / emugl / common / logging.h
1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef EMUGL_COMMON_LOGGING_H_
18 #define EMUGL_COMMON_LOGGING_H_
19
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wredundant-decls"
22
23 namespace emugl {
24 enum class LogLevel {
25   TRACE,
26   DEBUG,
27   INFO,
28   WARNING,
29   ERROR,
30   FATAL,
31 };
32 } // namespace emugl
33
34 typedef void (*logger_t)(const emugl::LogLevel &level, const char* fmt, ...);
35 extern logger_t emugl_logger;
36 extern logger_t emugl_cxt_logger;
37 void set_emugl_logger(logger_t f);
38 void set_emugl_cxt_logger(logger_t f);
39
40 #define GL_LOGGING 1
41
42 #if GL_LOGGING
43
44 #define GL_LOG(...) do { \
45     emugl_logger(__VA_ARGS__); \
46 } while (0)
47
48 #define GL_CXT_LOG(...) do { \
49     emugl_cxt_logger(__VA_ARGS__); \
50 } while (0)
51
52 #else
53 #define GL_LOG(...) 0
54 #endif
55
56 #pragma GCC diagnostic pop
57
58 #endif