Added DS-5 Streamline tracing support
[platform/core/uifw/dali-adaptor.git] / dali / internal / trace / streamline / streamline_annotate_logging.h
1 /* Copyright (C) 2021 by Arm Limited. All rights reserved. */
2
3 #ifndef STREAMLINE_ANNOTATE_LOGGING_H
4 #define STREAMLINE_ANNOTATE_LOGGING_H
5
6 //Mapped to android log levels - android_LogPriority
7 enum log_levels
8 {
9   LOG_UNKNOWN = 0,
10   LOG_DEFAULT,
11   LOG_VERBOSE,
12   LOG_DEBUG,
13   LOG_INFO,
14   LOG_WARN,
15   LOG_ERROR,
16   LOG_FATAL,
17   LOG_SILENT
18 };
19
20 /* ANDROID IMPLEMENTATION */
21 #if defined(ANDROID) || defined(__ANDROID__)
22 #include <android/log.h>
23
24 #define LOG_TAG "AnnotationLog"
25
26 #define LOGGING(LOG_LEVEL, fmt, ...) \
27   __android_log_print(LOG_LEVEL, LOG_TAG, "%s/%s:%d " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
28
29 /* LINUX IMPLEMENTATION */
30 #elif defined(linux) || defined(__linux) || defined(__linux__)
31 // clang-format off
32 char *log_levels[] = { "UNKNOWN",
33                        "DEFAULT",
34                        "VERBOSE",
35                        "DEBUG",
36                        "INFO",
37                        "WARN",
38                        "ERROR",
39                        "FATAL",
40                        "SILENT"};
41 // clang-format on
42 #define LOGGING(LOG_LEVEL, fmt, ...) \
43   printf("%s/%s:%d [%s] " fmt " \n", __FILE__, __func__, __LINE__, log_levels[LOG_LEVEL], ##__VA_ARGS__);
44
45 #endif
46 //Use to do logging, if not needed un-define this variable
47 #define ENABLE_LOG
48
49 #ifdef ENABLE_LOG
50 #define LOG(LOG_LEVEL, fmt, ...) LOGGING(LOG_LEVEL, fmt, ##__VA_ARGS__)
51 #else
52 #define LOG(LOG_LEVEL, fmt, ...) // nothing
53 #endif
54
55 #endif /* STREAMLINE_ANNOTATE_LOGGING_H */