1 /* Copyright (C) 2007-2008 The Android Open Source Project
2 **
3 ** Licensed under the Apache License, Version 2.0 (the "License");
4 ** you may not use this file except in compliance with the License.
5 ** You may obtain a copy of the License at
6 **
7 ** http://www.apache.org/licenses/LICENSE-2.0
8 **
9 ** Unless required by applicable law or agreed to in writing, software
10 ** distributed under the License is distributed on an "AS IS" BASIS,
11 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 ** See the License for the specific language governing permissions and
13 ** limitations under the License.
14 */
15 
16 #pragma once
17 
18 #include <stdarg.h>
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include <stdio.h>
22 
23 #include "aemu/base/logging/LogSeverity.h"
24 
25 #ifdef _MSC_VER
26 #ifdef LOGGING_API_SHARED
27 #define LOGGING_API __declspec(dllexport)
28 #else
29 #define LOGGING_API __declspec(dllimport)
30 #endif
31 #else
32 #define LOGGING_API
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 LOGGING_API void __emu_log_print(LogSeverity prio, const char* file, int line, const char* fmt, ...)
40     __attribute__((format(printf, 4, 5)));
41 
42 #ifndef EMULOG
43 #define EMULOG(priority, fmt, ...) \
44     __emu_log_print(priority, __FILE__, __LINE__, fmt, ##__VA_ARGS__);
45 #endif
46 
47 #ifndef dprint
48 // Logging support.
49 #define dprint(fmt, ...)                               \
50     if (EMULATOR_LOG_DEBUG >= getMinLogLevel()) {      \
51         EMULOG(EMULATOR_LOG_DEBUG, fmt, ##__VA_ARGS__) \
52     }
53 #endif
54 #ifndef dinfo
55 #define dinfo(fmt, ...)                               \
56     if (EMULATOR_LOG_INFO >= getMinLogLevel()) {      \
57         EMULOG(EMULATOR_LOG_INFO, fmt, ##__VA_ARGS__) \
58     }
59 #endif
60 #ifndef dwarning
61 #define dwarning(fmt, ...)                               \
62     if (EMULATOR_LOG_WARNING >= getMinLogLevel()) {      \
63         EMULOG(EMULATOR_LOG_WARNING, fmt, ##__VA_ARGS__) \
64     }
65 #endif
66 #ifndef derror
67 #define derror(fmt, ...)                               \
68     if (EMULATOR_LOG_ERROR >= getMinLogLevel()) {      \
69         EMULOG(EMULATOR_LOG_ERROR, fmt, ##__VA_ARGS__) \
70     }
71 #endif
72 #ifndef dfatal
73 #define dfatal(fmt, ...) EMULOG(EMULATOR_LOG_FATAL, fmt, ##__VA_ARGS__)
74 #endif
75 
76 #ifdef __cplusplus
77 }
78 #endif
79