• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 Huawei Device Co., Ltd.
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 #ifndef HISTREAMER_FOUNDATION_LOG_H
17 #define HISTREAMER_FOUNDATION_LOG_H
18 
19 #include <cinttypes>
20 #include <string>
21 
22 #ifdef MEDIA_OHOS
23 #include "hilog/log.h"
24 #else
25 #include "log_adapter.h"
26 #endif
27 
28 // If file name and line number is need, #define HST_DEBUG at the beginning of the cpp file.
29 #define HST_DEBUG
30 
31 #ifdef MEDIA_OHOS
32 #undef LOG_DOMAIN_SYSTEM_PLAYER
33 #define LOG_DOMAIN_SYSTEM_PLAYER 0xD002B22
34 #undef LOG_DOMAIN_STREAM_SOURCE
35 #define LOG_DOMAIN_STREAM_SOURCE 0xD002B23
36 #undef LOG_DOMAIN_FOUNDATION
37 #define LOG_DOMAIN_FOUNDATION    0xD002B24
38 #undef LOG_DOMAIN_DEMUXER
39 #define LOG_DOMAIN_DEMUXER       0xD002B3A
40 #undef LOG_DOMAIN_MUXER
41 #define LOG_DOMAIN_MUXER         0xD002B3B
42 #undef LOG_DOMAIN_AUDIO
43 #define LOG_DOMAIN_AUDIO         0xD002B31
44 #undef LOG_DOMAIN_PLAYER
45 #define LOG_DOMAIN_PLAYER        0xD002B2B
46 #undef LOG_DOMAIN_RECORDER
47 #define LOG_DOMAIN_RECORDER      0xD002B2C
48 #undef LOG_DOMAIN_SCREENCAPTURE
49 #define LOG_DOMAIN_SCREENCAPTURE 0xD002B2E
50 #undef LOG_DOMAIN_HIPLAYER
51 #define LOG_DOMAIN_HIPLAYER      0xD002B2D
52 #undef LOG_DOMAIN_METADATA
53 #define LOG_DOMAIN_METADATA      0xD002B2C
54 #define PUBLIC_LOG "%{public}"
55 #else
56 #define PUBLIC_LOG "%"
57 #endif
58 
59 #ifndef HST_LOG_TAG
60 #define HST_LOG_TAG "NULL"
61 #endif
62 
63 #define PUBLIC_LOG_C PUBLIC_LOG "c"
64 #define PUBLIC_LOG_S PUBLIC_LOG "s"
65 #define PUBLIC_LOG_D8 PUBLIC_LOG PRId8
66 #define PUBLIC_LOG_D16 PUBLIC_LOG PRId16
67 #define PUBLIC_LOG_D32 PUBLIC_LOG PRId32
68 #define PUBLIC_LOG_D64 PUBLIC_LOG PRId64
69 #define PUBLIC_LOG_U8 PUBLIC_LOG PRIu8
70 #define PUBLIC_LOG_U16 PUBLIC_LOG PRIu16
71 #define PUBLIC_LOG_U32 PUBLIC_LOG PRIu32
72 #define PUBLIC_LOG_U64 PUBLIC_LOG PRIu64
73 #define PUBLIC_LOG_U32X "0x" PUBLIC_LOG PRIx32
74 #define PUBLIC_LOG_F PUBLIC_LOG "f"
75 #define PUBLIC_LOG_P PUBLIC_LOG "p"
76 #define PUBLIC_LOG_ZU PUBLIC_LOG "zu"
77 
78 #undef LOG_TAG
79 #define LOG_TAG LABEL.tag
80 #undef LOG_DOMAIN
81 #define LOG_DOMAIN LABEL.domain
82 #undef LOG_TYPE
83 #define LOG_TYPE LABEL.type
84 
85 
86 #ifdef MEDIA_OHOS
87 #ifndef HST_DEBUG
88 #define HST_HILOG(op, fmt, args...)                              \
89     do {                                                         \
90         op(LOG_TYPE, PUBLIC_LOG_S ":" fmt, HST_LOG_TAG, ##args); \
91     } while (0)
92 #else
93 #define HST_HILOG(op, fmt, args...)                                                                     \
94     do {                                                                                                \
95         op(LOG_TYPE, "(" PUBLIC_LOG_S "(), " PUBLIC_LOG_D32 "): " fmt, __FUNCTION__, __LINE__, ##args); \
96     } while (0)
97 #define HST_HILOG_SHORT(op, fmt, args...)                           \
98     do {                                                            \
99         op(LOG_TYPE, "#" PUBLIC_LOG_D32 " " fmt, __LINE__, ##args); \
100     } while (0)
101 #define HST_HILOG_NO_RELEASE(op, fmt, args...)                                                                     \
102     do {                                                                                                           \
103         op(LOG_ONLY_PRERELEASE, "(" PUBLIC_LOG_S "(), " PUBLIC_LOG_D32 "): " fmt, __FUNCTION__, __LINE__, ##args); \
104     } while (0)
105 
106 #define HST_HILOG_TAG(op, fmt, args...)                               \
107     do {                                                              \
108         op(LOG_TYPE, "[" PUBLIC_LOG_S "]:" fmt, HST_LOG_TAG, ##args); \
109     } while (0)
110 
111 #define HST_HILOG_WITH_LEVEL_JUDGE(op1, op2, con, fmt, args...)                                              \
112     do {                                                                                                     \
113         if (!con) {                                                                                          \
114             op2(LOG_TYPE, "(" PUBLIC_LOG_S "(), " PUBLIC_LOG_D32 "): " fmt, __FUNCTION__, __LINE__, ##args); \
115         } else {                                                                                             \
116             op1(LOG_TYPE, "(" PUBLIC_LOG_S "(), " PUBLIC_LOG_D32 "): " fmt, __FUNCTION__, __LINE__, ##args); \
117         }                                                                                                    \
118     } while (0)
119 #endif
120 
121 #define MEDIA_LOG_D(fmt, ...) HST_HILOG(HILOG_DEBUG, fmt, ##__VA_ARGS__)
122 #define MEDIA_LOG_I(fmt, ...) HST_HILOG(HILOG_INFO, fmt, ##__VA_ARGS__)
123 #define MEDIA_LOG_W(fmt, ...) HST_HILOG(HILOG_WARN, fmt, ##__VA_ARGS__)
124 #define MEDIA_LOG_E(fmt, ...) HST_HILOG(HILOG_ERROR, fmt, ##__VA_ARGS__)
125 #define MEDIA_LOG_F(fmt, ...) HST_HILOG(HILOG_FATAL, fmt, ##__VA_ARGS__)
126 #define MEDIA_LOG_I_NO_RELEASE(fmt, ...) HST_HILOG_NO_RELEASE(HILOG_INFO, fmt, ##__VA_ARGS__)
127 #define MEDIA_LOG_W_NO_RELEASE(fmt, ...) HST_HILOG_NO_RELEASE(HILOG_WARN, fmt, ##__VA_ARGS__)
128 #define MEDIA_LOG_E_NO_RELEASE(fmt, ...) HST_HILOG_NO_RELEASE(HILOG_ERROR, fmt, ##__VA_ARGS__)
129 #define MEDIA_LOG_F_NO_RELEASE(fmt, ...) HST_HILOG_NO_RELEASE(HILOG_FATAL, fmt, ##__VA_ARGS__)
130 #define MEDIA_LOG_D_SHORT(fmt, ...) HST_HILOG_SHORT(HILOG_DEBUG, fmt, ##__VA_ARGS__)
131 #define MEDIA_LOG_I_SHORT(fmt, ...) HST_HILOG_SHORT(HILOG_INFO, fmt, ##__VA_ARGS__)
132 #define MEDIA_LOG_W_SHORT(fmt, ...) HST_HILOG_SHORT(HILOG_WARN, fmt, ##__VA_ARGS__)
133 #define MEDIA_LOG_E_SHORT(fmt, ...) HST_HILOG_SHORT(HILOG_ERROR, fmt, ##__VA_ARGS__)
134 #define MEDIA_LOG_F_SHORT(fmt, ...) HST_HILOG_SHORT(HILOG_FATAL, fmt, ##__VA_ARGS__)
135 #define MEDIA_LOG_I_FALSE_D(con, fmt, ...) \
136     HST_HILOG_WITH_LEVEL_JUDGE(HILOG_INFO, HILOG_DEBUG, con, fmt, ##__VA_ARGS__)
137 
138 #define HST_HILOG_T_WITH_LEVEL_JUDGE(op1, op2, con, fmt, args...)           \
139     do {                                                                    \
140         if (!con) {                                                         \
141             op2(LOG_TYPE, "[" PUBLIC_LOG_S "]:" fmt, HST_LOG_TAG, ##args);  \
142         } else {                                                            \
143             op1(LOG_TYPE, "[" PUBLIC_LOG_S "]:" fmt, HST_LOG_TAG, ##args);  \
144         }                                                                   \
145     } while (0)
146 
147 #define MEDIA_LOG_D_T(fmt, ...) HST_HILOG_TAG(HILOG_DEBUG, fmt, ##__VA_ARGS__)
148 #define MEDIA_LOG_I_T(fmt, ...) HST_HILOG_TAG(HILOG_INFO, fmt, ##__VA_ARGS__)
149 #define MEDIA_LOG_W_T(fmt, ...) HST_HILOG_TAG(HILOG_WARN, fmt, ##__VA_ARGS__)
150 #define MEDIA_LOG_E_T(fmt, ...) HST_HILOG_TAG(HILOG_ERROR, fmt, ##__VA_ARGS__)
151 #define MEDIA_LOG_F_T(fmt, ...) HST_HILOG_TAG(HILOG_FATAL, fmt, ##__VA_ARGS__)
152 #define MEDIA_LOG_I_FALSE_D_T(con, fmt, ...)                                      \
153     HST_HILOG_T_WITH_LEVEL_JUDGE(HILOG_INFO, HILOG_DEBUG, con, fmt, ##__VA_ARGS__)
154 
155 #define MEDIA_LOG_LIMIT(op, frequency, fmt, ...)             \
156     do {                                                     \
157         static uint64_t currentTimes = 0;                    \
158         if (currentTimes++ % ((uint32_t)(frequency)) == 0) { \
159             op(fmt, ##__VA_ARGS__);                          \
160         }                                                    \
161     } while (0)
162 
163 #define MEDIA_LOGE_LIMIT(frequency, fmt, ...) MEDIA_LOG_LIMIT(MEDIA_LOG_E, frequency, fmt, ##__VA_ARGS__)
164 #define MEDIA_LOGW_LIMIT(frequency, fmt, ...) MEDIA_LOG_LIMIT(MEDIA_LOG_W, frequency, fmt, ##__VA_ARGS__)
165 #define MEDIA_LOGI_LIMIT(frequency, fmt, ...) MEDIA_LOG_LIMIT(MEDIA_LOG_I, frequency, fmt, ##__VA_ARGS__)
166 #define MEDIA_LOGD_LIMIT(frequency, fmt, ...) MEDIA_LOG_LIMIT(MEDIA_LOG_D, frequency, fmt, ##__VA_ARGS__)
167 #endif
168 
169 // Control the MEDIA_LOG_D.
170 // If MEDIA_LOG_D is needed, #define MEDIA_LOG_DEBUG 1 at the beginning of the cpp file.
171 #ifndef MEDIA_LOG_DEBUG
172 #define MEDIA_LOG_DEBUG 1
173 #endif
174 
175 #if !MEDIA_LOG_DEBUG
176 #undef MEDIA_LOG_D
177 #define MEDIA_LOG_D(msg, ...) ((void)0)
178 #endif
179 
180 // Control the debug detail logs MEDIA_LOG_DD.
181 // If MEDIA_LOG_DD is needed, #define MEDIA_LOG_DEBUG_DETAIL 1 at the beginning of the cpp file.
182 #ifndef MEDIA_LOG_DEBUG_DETAIL
183 #define MEDIA_LOG_DEBUG_DETAIL 0
184 #endif
185 
186 #if !MEDIA_LOG_DEBUG_DETAIL
187 #undef MEDIA_LOG_DD
188 #define MEDIA_LOG_DD(msg, ...) ((void)0)
189 #else
190 #undef MEDIA_LOG_DD
191 #define MEDIA_LOG_DD MEDIA_LOG_D
192 #endif
193 
194 #ifndef NOK_RETURN
195 #define NOK_RETURN(exec)                                                           \
196     do {                                                                           \
197         Status returnValue = (exec);                                               \
198         if (returnValue != Status::OK) {                                           \
199             MEDIA_LOG_E("NOK_RETURN on Status(" PUBLIC_LOG_D32 ").", returnValue); \
200             return returnValue;                                                    \
201         }                                                                          \
202     } while (0)
203 #endif
204 
205 #ifndef NOK_LOG
206 #define NOK_LOG(exec)                                                           \
207     do {                                                                        \
208         Status returnValue = (exec);                                            \
209         if (returnValue != Status::OK) {                                        \
210             MEDIA_LOG_E("NOK_LOG on Status(" PUBLIC_LOG_D32 ").", returnValue); \
211         }                                                                       \
212     } while (0)
213 #endif
214 
215 // If exec not return zero, then record the error code, especially when call system C function.
216 #ifndef NZERO_LOG
217 #define NZERO_LOG(exec)                                                                          \
218     do {                                                                                         \
219         int returnValue = (exec);                                                                \
220         if (returnValue != 0) {                                                                  \
221             MEDIA_LOG_E("NZERO_LOG when call (" #exec "), return " PUBLIC_LOG_D32, returnValue); \
222         }                                                                                        \
223     } while (0)
224 #endif
225 
226 #ifndef NZERO_RETURN
227 #define NZERO_RETURN(exec)                                                                          \
228     do {                                                                                            \
229         int returnValue = (exec);                                                                   \
230         if (returnValue != 0) {                                                                     \
231             MEDIA_LOG_E("NZERO_RETURN when call (" #exec "), return " PUBLIC_LOG_D32, returnValue); \
232             return returnValue;                                                                     \
233         }                                                                                           \
234     } while (0)
235 #endif
236 
237 #ifndef NZERO_RETURN_V
238 #define NZERO_RETURN_V(exec, ret)                                                                     \
239     do {                                                                                              \
240         int returnValue = (exec);                                                                     \
241         if (returnValue != 0) {                                                                       \
242             MEDIA_LOG_E("NZERO_RETURN_V when call (" #exec "), return " PUBLIC_LOG_D32, returnValue); \
243             return ret;                                                                               \
244         }                                                                                             \
245     } while (0)
246 #endif
247 
248 #ifndef FALSE_RETURN
249 #define FALSE_RETURN(exec)                                              \
250     do {                                                                \
251         if (!(exec)) {                                                  \
252             MEDIA_LOG_E_NO_RELEASE("FALSE_RETURN " #exec);              \
253             return;                                                     \
254         }                                                               \
255     } while (0)
256 #endif
257 
258 #ifndef FALSE_RETURN_NOLOG
259 #define FALSE_RETURN_NOLOG(exec)                                        \
260     do {                                                                \
261         if (!(exec)) {                                                  \
262             return;                                                     \
263         }                                                               \
264     } while (0)
265 #endif
266 
267 #ifndef FALSE_GOON_NOEXEC
268 #define FALSE_GOON_NOEXEC(cond, exec)                                   \
269     if (cond) {                                                         \
270         (exec);                                                         \
271     } else                                                              \
272         ((void)0)
273 #endif
274 
275 #ifndef FALSE_CONTINUE_NOLOG
276 #define FALSE_CONTINUE_NOLOG(cond)                                      \
277     if (!(cond)) {                                                      \
278         continue;                                                       \
279     } else                                                              \
280         ((void)0)
281 #endif
282 
283 #ifndef FALSE_CONTINUE_LOG_IMPL
284 #define FALSE_CONTINUE_LOG_IMPL(loglevel, cond, fmt, args...)           \
285     if (!(cond)) {                                                      \
286         loglevel(fmt, ##args);                                          \
287         continue;                                                       \
288     } else                                                              \
289         ((void)0)
290 #endif
291 
292 #define TRUE_LOG(cond, func, fmt, ...)         \
293     if (1) {                                   \
294         if ((cond)) {                          \
295             func(fmt, ##__VA_ARGS__);          \
296         }                                      \
297     } else                                     \
298         void(0)
299 
300 #ifndef FALSE_CONTINUE_LOGDD
301 #define FALSE_CONTINUE_LOGDD(cond, fmt, args...) FALSE_CONTINUE_LOG_IMPL(MEDIA_LOG_DD, cond, fmt, ##args)
302 #endif
303 
304 #ifndef FALSE_CONTINUE_LOGD
305 #define FALSE_CONTINUE_LOGD(cond, fmt, args...) FALSE_CONTINUE_LOG_IMPL(MEDIA_LOG_D, cond, fmt, ##args)
306 #endif
307 
308 #ifndef FALSE_CONTINUE_LOGI
309 #define FALSE_CONTINUE_LOGI(cond, fmt, args...) FALSE_CONTINUE_LOG_IMPL(MEDIA_LOG_I, cond, fmt, ##args)
310 #endif
311 
312 #ifndef FALSE_BREAK_NOLOG
313 #define FALSE_BREAK_NOLOG(cond)                                         \
314     if (!(cond)) {                                                      \
315         break;                                                          \
316     } else                                                              \
317         ((void)0)
318 #endif
319 
320 #ifndef FALSE_BREAK_LOG_IMPL
321 #define FALSE_BREAK_LOG_IMPL(loglevel, cond, fmt, args...)              \
322     if (!(cond)) {                                                      \
323         loglevel(fmt, ##args);                                          \
324         break;                                                          \
325     } else                                                              \
326         ((void)0)
327 #endif
328 
329 #ifndef FALSE_BREAK_LOGDD
330 #define FALSE_BREAK_LOGDD(cond, fmt, args...) FALSE_BREAK_LOG_IMPL(MEDIA_LOG_DD, cond, fmt, ##args)
331 #endif
332 
333 #ifndef FALSE_BREAK_LOGD
334 #define FALSE_BREAK_LOGD(cond, fmt, args...) FALSE_BREAK_LOG_IMPL(MEDIA_LOG_D, cond, fmt, ##args)
335 #endif
336 
337 #ifndef FALSE_BREAK_LOGI
338 #define FALSE_BREAK_LOGI(cond, fmt, args...) FALSE_BREAK_LOG_IMPL(MEDIA_LOG_I, cond, fmt, ##args)
339 #endif
340 
341 #ifndef FALSE_EXEC_RETURN_MSG_IMPL
342 #define FALSE_EXEC_RETURN_MSG_IMPL(loglevel, cond, exec, fmt, args...)                  \
343     if (!(cond)) {                                                                      \
344         (exec);                                                                         \
345         loglevel("FALSE RETURN " #cond ", " fmt, ##args);                               \
346         return;                                                                         \
347     } else                                                                              \
348         ((void)0)
349 #endif
350 
351 #ifndef FALSE_EXEC_RETURN_MSG
352 #define FALSE_EXEC_RETURN_MSG(cond, exec, fmt, args...)                                 \
353         FALSE_EXEC_RETURN_MSG_IMPL(MEDIA_LOG_W, cond, exec, fmt, ##args)
354 #endif
355 
356 #ifndef FALSE_EXEC_RETURN_MSG_DD
357 #define FALSE_EXEC_RETURN_MSG_DD(cond, exec, fmt, args...)                              \
358         FALSE_EXEC_RETURN_MSG_IMPL(MEDIA_LOG_DD, cond, exec, fmt, ##args)
359 #endif
360 
361 #ifndef FALSE_EXEC_RETURN_MSG_D
362 #define FALSE_EXEC_RETURN_MSG_D(cond, exec, fmt, args...)                               \
363         FALSE_EXEC_RETURN_MSG_IMPL(MEDIA_LOG_D, cond, exec, fmt, ##args)
364 #endif
365 
366 #ifndef FALSE_EXEC_RETURN_MSG_I
367 #define FALSE_EXEC_RETURN_MSG_I(cond, exec, fmt, args...)                               \
368         FALSE_EXEC_RETURN_MSG_IMPL(MEDIA_LOG_I, cond, exec, fmt, ##args)
369 #endif
370 
371 #ifndef FALSE_EXEC_RETURN_MSG_W
372 #define FALSE_EXEC_RETURN_MSG_W(cond, exec, fmt, args...)                               \
373         FALSE_EXEC_RETURN_MSG_IMPL(MEDIA_LOG_W, cond, exec, fmt, ##args)
374 #endif
375 
376 #ifndef FALSE_EXEC_RETURN_MSG_E
377 #define FALSE_EXEC_RETURN_MSG_E(cond, exec, fmt, args...)                               \
378         FALSE_EXEC_RETURN_MSG_IMPL(MEDIA_LOG_E, cond, exec, fmt, ##args)
379 #endif
380 
381 #ifndef FALSE_RETURN_W
382 #define FALSE_RETURN_W(exec)                                            \
383     do {                                                                \
384         if (!(exec)) {                                                  \
385             MEDIA_LOG_W("FALSE_RETURN " #exec);                         \
386             return;                                                     \
387         }                                                               \
388     } while (0)
389 #endif
390 
391 #ifndef FALSE_RETURN_V
392 #define FALSE_RETURN_V(exec, ret)                                       \
393     do {                                                                \
394         if (!(exec)) {                                                  \
395             MEDIA_LOG_E_NO_RELEASE("FALSE_RETURN_V " #exec);            \
396             return ret;                                                 \
397         }                                                               \
398     } while (0)
399 #endif
400 
401 #ifndef FALSE_RETURN_V_NOLOG
402 #define FALSE_RETURN_V_NOLOG(exec, ret)                                 \
403     do {                                                                \
404         if (!(exec)) {                                                  \
405             return ret;                                                 \
406         }                                                               \
407     } while (0)
408 #endif
409 
410 #ifndef FALSE_RETURN_V_W
411 #define FALSE_RETURN_V_W(exec, ret)                                     \
412     do {                                                                \
413         if (!(exec)) {                                                  \
414             MEDIA_LOG_W("FALSE_RETURN_V_W " #exec);                     \
415             return ret;                                                 \
416         }                                                               \
417     } while (0)
418 #endif
419 
420 #ifndef FALSE_RETURN_MSG_IMPL
421 #define FALSE_RETURN_MSG_IMPL(loglevel, exec, fmt, args...)             \
422     do {                                                                \
423         if (!(exec)) {                                                  \
424             loglevel(fmt, ##args);                                      \
425             return;                                                     \
426         }                                                               \
427     } while (0)
428 #endif
429 
430 #ifndef FALSE_RETURN_MSG
431 #define FALSE_RETURN_MSG(exec, fmt, args...) FALSE_RETURN_MSG_IMPL(MEDIA_LOG_E, exec, fmt, ##args)
432 #endif
433 
434 #ifndef FALSE_RETURN_MSG_D
435 #define FALSE_RETURN_MSG_D(exec, fmt, args...) FALSE_RETURN_MSG_IMPL(MEDIA_LOG_D, exec, fmt, ##args)
436 #endif
437 
438 #ifndef FALSE_RETURN_MSG_I
439 #define FALSE_RETURN_MSG_I(exec, fmt, args...) FALSE_RETURN_MSG_IMPL(MEDIA_LOG_I, exec, fmt, ##args)
440 #endif
441 
442 #ifndef FALSE_RETURN_MSG_W
443 #define FALSE_RETURN_MSG_W(exec, fmt, args...) FALSE_RETURN_MSG_IMPL(MEDIA_LOG_W, exec, fmt, ##args)
444 #endif
445 
446 #ifndef FALSE_RETURN_V_MSG_IMPL
447 #define FALSE_RETURN_V_MSG_IMPL(loglevel, exec, ret, fmt, args...)      \
448     do {                                                                \
449         if (!(exec)) {                                                  \
450             loglevel(fmt, ##args);                                      \
451             return ret;                                                 \
452         }                                                               \
453     } while (0)
454 #endif
455 
456 #ifndef FALSE_RETURN_V_MSG
457 #define FALSE_RETURN_V_MSG(exec, ret, fmt, args...) FALSE_RETURN_V_MSG_IMPL(MEDIA_LOG_E, exec, ret, fmt, ##args)
458 #endif
459 
460 #ifndef FALSE_RETURN_V_MSG_DD
461 #define FALSE_RETURN_V_MSG_DD(exec, ret, fmt, args...) FALSE_RETURN_V_MSG_IMPL(MEDIA_LOG_DD, exec, ret, fmt, ##args)
462 #endif
463 
464 #ifndef FALSE_RETURN_V_MSG_D
465 #define FALSE_RETURN_V_MSG_D(exec, ret, fmt, args...) FALSE_RETURN_V_MSG_IMPL(MEDIA_LOG_D, exec, ret, fmt, ##args)
466 #endif
467 
468 #ifndef FALSE_RETURN_V_MSG_I
469 #define FALSE_RETURN_V_MSG_I(exec, ret, fmt, args...) FALSE_RETURN_V_MSG_IMPL(MEDIA_LOG_I, exec, ret, fmt, ##args)
470 #endif
471 
472 #ifndef FALSE_RETURN_V_MSG_W
473 #define FALSE_RETURN_V_MSG_W(exec, ret, fmt, args...) FALSE_RETURN_V_MSG_IMPL(MEDIA_LOG_W, exec, ret, fmt, ##args)
474 #endif
475 
476 #ifndef FALSE_RETURN_V_MSG_E
477 #define FALSE_RETURN_V_MSG_E(exec, ret, fmt, args...) FALSE_RETURN_V_MSG_IMPL(MEDIA_LOG_E, exec, ret, fmt, ##args)
478 #endif
479 
480 #ifndef FALSE_UPDATE_RETURN_V_MSG_IMPL
481 #define FALSE_UPDATE_RETURN_V_MSG_IMPL(loglevel, val, exec, ret, fmt, args...)  \
482     do {                                                                        \
483         if (!(exec)) {                                                          \
484             val = ret;                                                          \
485             loglevel(fmt, ##args);                                              \
486             return ret;                                                         \
487         }                                                                       \
488     } while (0)
489 #endif
490 
491 #ifndef FALSE_UPDATE_RETURN_V_MSG_E
492 #define FALSE_UPDATE_RETURN_V_MSG_E(exec, val, ret, fmt, args...) \
493     FALSE_UPDATE_RETURN_V_MSG_IMPL(MEDIA_LOG_E, val, exec, ret, fmt, ##args)
494 #endif
495 
496 #ifndef FALSE_LOG
497 #define FALSE_LOG(exec)                                     \
498     do {                                                    \
499         if (!(exec)) {                                      \
500             MEDIA_LOG_E("FALSE_LOG: " #exec);               \
501         }                                                   \
502     } while (0)
503 #endif
504 
505 #ifndef FALSE_LOG_MSG_IMPL
506 #define FALSE_LOG_MSG_IMPL(loglevel, exec, fmt, args...)    \
507     do {                                                    \
508         if (!(exec)) {                                      \
509             loglevel(fmt, ##args);                          \
510         }                                                   \
511     } while (0)
512 #endif
513 
514 #ifndef FALSE_LOG_MSG
515 #define FALSE_LOG_MSG(exec, fmt, args...) FALSE_LOG_MSG_IMPL(MEDIA_LOG_E, exec, fmt, ##args)
516 #endif
517 
518 #ifndef FALSE_LOG_MSG_DD
519 #define FALSE_LOG_MSG_DD(exec, fmt, args...) FALSE_LOG_MSG_IMPL(MEDIA_LOG_DD, exec, fmt, ##args)
520 #endif
521 
522 #ifndef FALSE_LOG_MSG_D
523 #define FALSE_LOG_MSG_D(exec, fmt, args...) FALSE_LOG_MSG_IMPL(MEDIA_LOG_D, exec, fmt, ##args)
524 #endif
525 
526 #ifndef FALSE_LOG_MSG_W
527 #define FALSE_LOG_MSG_W(exec, fmt, args...) FALSE_LOG_MSG_IMPL(MEDIA_LOG_W, exec, fmt, ##args)
528 #endif
529 
530 #define POINTER_MASK 0x00FFFFFF
531 #define FAKE_POINTER(addr) (POINTER_MASK & reinterpret_cast<uintptr_t>(addr))
532 #endif  // HISTREAMER_FOUNDATION_LOG_H