Use full form rather than abbreviations
[platform/core/multimedia/noise-suppression.git] / include / log.h
1 /**
2  * Copyright (c) 2022-2023 Samsung Electronics Co., Ltd.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * - Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * - Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * - Neither the name of the Samsung Electronics Co., Ltd. nor the names
16  * of its contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef __TEST_SERVICE_LOG_H__
33 #define __TEST_SERVICE_LOG_H__
34
35 #include <stdio.h>
36 #include <string.h>
37 #include "NSLogger.h"
38
39 #define LOGI(fmt, arg...)  noise_suppression_print("[I] " fmt, ##arg)
40 #define LOGE(fmt, arg...)  noise_suppression_print("[E] " fmt, ##arg)
41 #define LOGD(fmt, arg...)  noise_suppression_print("[D] " fmt, ##arg)
42
43 #define COLOR_YELLOW "\033[1;40;33m"
44 #define COLOR_RED   "\033[0;40;31m"
45 #define COLOR_BLUE  "\033[1;40;34m"
46 #define COLOR_BRIGHT_BLUE   "\033[1;40;34m" /* 4 brightblue */
47 #define COLOR_WHITE "\033[1;40;37m" /* 7 white */
48
49
50 #define COLOR_LIGHT_RED      "\033[91m"
51 #define COLOR_LIGHT_YELLOW   "\033[93m"
52 #define COLOR_CLEAR          "\033[0m"
53 #define COLOR_END "\033[0;m"
54
55
56 enum e_debugLogList
57 {
58     D_LV_IMPORTANT=0,
59     D_LV_NORMAL,
60     D_LV_MIN
61 };
62
63 #define DEBUG_LOG_LV D_LV_MIN
64
65 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
66
67 #define _I(fmt, arg...)  LOGI(COLOR_YELLOW "%s : %s(%d) > " fmt COLOR_END, __FILENAME__, __FUNCTION__, __LINE__, ##arg)
68 #define _E(fmt, arg...)  LOGE(COLOR_RED "%s : %s(%d) > " fmt COLOR_END, __FILENAME__, __FUNCTION__, __LINE__, ##arg)
69 #define _D(fmt, arg...)  LOGD("%s : %s(%d) > " fmt, __FILENAME__, __FUNCTION__, __LINE__, ##arg)
70
71 #define _DL(level, fmt, arg...) \
72 do { \
73         if(level <= DEBUG_LOG_LV) { \
74             if(level <= D_LV_IMPORTANT) { \
75                 LOGD(COLOR_BRIGHT_BLUE "%s : %s(%d) > " fmt COLOR_END, __FILENAME__, __FUNCTION__, __LINE__, ##arg); \
76             } else { \
77                 LOGD("%s : %s(%d) > " fmt, __FILENAME__, __FUNCTION__, __LINE__, ##arg); \
78             } \
79         } \
80     } \
81 while (0)
82
83 #define FN_START        _DL(D_LV_MIN, "* Enter *");
84 #define FN_END          _DL(D_LV_MIN, "* End *");
85
86 #define ret_if(expr) \
87         do { \
88                 if (expr) { \
89                         _E("(%s) return", #expr); \
90                         return; \
91                 } \
92         } while (0)
93
94 #define retv_if(expr, val) \
95         do { \
96                 if (expr) { \
97                         _E("(%s) return", #expr); \
98                         return (val); \
99                 } \
100         } while (0)
101
102
103 #endif