Doxygen Book
nnstreamer_log.h
Go to the documentation of this file.
1 
24 #ifndef __NNSTREAMER_LOG_H__
25 #define __NNSTREAMER_LOG_H__
26 
27 #include <stdlib.h>
28 #define TAG_NAME "nnstreamer"
29 
30 #if defined(__TIZEN__)
31 
33 #ifndef FAKEDLOG
34 #include <dlog.h>
35 #else
36 
37 #include "../../tests/unittest_util.h"
38 #endif
39 
40 #define ml_logi(...) \
41  dlog_print (DLOG_INFO, TAG_NAME, __VA_ARGS__)
42 
43 #define ml_logw(...) \
44  dlog_print (DLOG_WARN, TAG_NAME, __VA_ARGS__)
45 
46 #define ml_loge(...) \
47  dlog_print (DLOG_ERROR, TAG_NAME, __VA_ARGS__)
48 
49 #define ml_logd(...) \
50  dlog_print (DLOG_DEBUG, TAG_NAME, __VA_ARGS__)
51 
52 #define ml_logf(...) \
53  dlog_print (DLOG_FATAL, TAG_NAME, __VA_ARGS__)
54 
55 #elif defined(__ANDROID__)
56 #include <android/log.h>
57 
58 #define ml_logi(...) \
59  __android_log_print (ANDROID_LOG_INFO, TAG_NAME, __VA_ARGS__)
60 
61 #define ml_logw(...) \
62  __android_log_print (ANDROID_LOG_WARN, TAG_NAME, __VA_ARGS__)
63 
64 #define ml_loge(...) \
65  __android_log_print (ANDROID_LOG_ERROR, TAG_NAME, __VA_ARGS__)
66 
67 #define ml_logd(...) \
68  __android_log_print (ANDROID_LOG_DEBUG, TAG_NAME, __VA_ARGS__)
69 
70 #define ml_logf(...) \
71  __android_log_print (ANDROID_LOG_FATAL, TAG_NAME, __VA_ARGS__)
72 
73 #else /* Linux distro */
74 #include <glib.h>
75 
76 #define ml_logi g_info
77 #define ml_logw g_warning
78 #define ml_loge g_critical
79 #define ml_logd g_debug
80 #define ml_logf g_error
81 #endif
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
91 extern char *
93 
94 #define GST_ELEMENT_ERROR_BTRACE(s, errtype, errcode, mesg) do { \
95  char *btrace = _backtrace_to_string (); \
96  if (btrace) { \
97  GST_ELEMENT_ERROR (s, errtype, errcode, mesg, ("%s", btrace)); \
98  free (btrace); \
99  } \
100  } while (0)
101 
102 #define ml_logf_stacktrace(...) do { \
103  char *btrace = _backtrace_to_string (); \
104  if (btrace) { \
105  ml_loge ("%s\n", btrace); \
106  free (btrace); \
107  } \
108  ml_logf (__VA_ARGS__); \
109  } while (0)
110 
111 #define ml_log_stacktrace(logfunc, ...) do { \
112  char *btrace = _backtrace_to_string (); \
113  if (btrace) { \
114  logfunc ("%s\n", btrace); \
115  free (btrace); \
116  } \
117  logfunc (__VA_ARGS__); \
118  } while (0)
119 #define ml_loge_stacktrace(...) ml_log_stacktrace(ml_loge, __VA_ARGS__)
120 
125 extern const char *
126 _nnstreamer_error (void);
127 
131 extern void
132 _nnstreamer_error_write (const char *fmt, ...);
133 
137 extern void
139 
140 #define nns_logi ml_logi
141 #define nns_logw ml_logw
142 #define nns_loge ml_loge
143 #define nns_logd ml_logd
144 #define nns_logf ml_logf
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* __NNSTREAMER_LOG_H__ */
_backtrace_to_string
char * _backtrace_to_string(void)
stack trace as a string for error messages
Definition: nnstreamer_log.c:35
_nnstreamer_error_clean
void _nnstreamer_error_clean(void)
cleans up the error message buffer.
Definition: nnstreamer_log.c:120
_nnstreamer_error
const char * _nnstreamer_error(void)
return the last internal error string and clean it.
Definition: nnstreamer_log.c:81
_nnstreamer_error_write
void _nnstreamer_error_write(const char *fmt,...)
overwrites the error message buffer with the new message.