• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------------
2  * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
3  * Description: los_printf
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  * 1. Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
9  * of conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  * --------------------------------------------------------------------------- */
26 
27 /**
28  * @defgroup los_printf Printf
29  * @ingroup kernel
30  */
31 
32 #ifndef _LOS_PRINTF_H
33 #define _LOS_PRINTF_H
34 
35 #include "los_typedef.h"
36 #include "los_config.h"
37 
38 #ifdef __cplusplus
39 #if __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42 #endif /* __cplusplus */
43 
44 #define LOS_EMG_LEVEL   0
45 
46 #define LOS_COMMOM_LEVEL   (LOS_EMG_LEVEL + 1)
47 
48 #define LOS_ERR_LEVEL   (LOS_COMMOM_LEVEL + 1)
49 
50 #define LOS_WARN_LEVEL  (LOS_ERR_LEVEL + 1)
51 
52 #define LOS_INFO_LEVEL  (LOS_WARN_LEVEL + 1)
53 
54 #define LOS_DEBUG_LEVEL (LOS_INFO_LEVEL + 1)
55 
56 #ifdef GCOVERAGE
57 #define PRINT_LEVEL 0
58 #else
59 #define PRINT_LEVEL LOS_ERR_LEVEL
60 #endif
61 
62 extern int printf(const char *fmt, ...);
63 #define  los_printf (VOID)printf
64 
65 /**
66  * @ingroup los_printf
67  * @brief Format and print data.
68  *
69  * @par Description:
70  * Print argument(s) according to fmt.
71  *
72  * @attention
73  * <ul>
74  * <li>None</li>
75  * </ul>
76  *
77  * @param fmt [IN] Type char* controls the ouput as in C printf.
78  *
79  * @retval None
80  * @par Dependency:
81  * <ul><li>los_printf.h: the header file that contains the API declaration.</li></ul>
82  * @see printf
83  */
84 #define diag_printf los_printf
85 
86 #if PRINT_LEVEL < LOS_DEBUG_LEVEL
87 #define PRINT_DEBUG(fmt, args...)
88 #else
89 #define PRINT_DEBUG(fmt, args...)   do { (los_printf("[DEBUG] "), los_printf(fmt, ##args)); } while (0)
90 #endif
91 
92 #if PRINT_LEVEL < LOS_INFO_LEVEL
93 #define PRINT_INFO(fmt, args...)
94 #else
95 #define PRINT_INFO(fmt, args...)    do { (los_printf("[INFO] "), los_printf(fmt, ##args)); } while (0)
96 #endif
97 
98 #if PRINT_LEVEL < LOS_WARN_LEVEL
99 #define PRINT_WARN(fmt, args...)
100 #else
101 #define PRINT_WARN(fmt, args...)    do { (los_printf("[WARN] "), los_printf(fmt, ##args)); } while (0)
102 #endif
103 
104 #if PRINT_LEVEL < LOS_ERR_LEVEL
105 #define PRINT_ERR(fmt, args...)
106 #else
107 #define PRINT_ERR(fmt, args...)     do { (los_printf("[ERR] "), los_printf(fmt, ##args)); } while (0)
108 #endif
109 
110 #if PRINT_LEVEL < LOS_COMMOM_LEVEL
111 #define PRINTK(fmt, args...)
112 #else
113 #define PRINTK(fmt, args...)     los_printf(fmt, ##args)
114 #endif
115 
116 #if PRINT_LEVEL < LOS_EMG_LEVEL
117 #define PRINT_EMG(fmt, args...)
118 #else
119 #define PRINT_EMG(fmt, args...)     do { (los_printf("[EMG] "), los_printf(fmt, ##args)); } while (0)
120 #endif
121 
122 #define PRINT_RELEASE(fmt, args...)   los_printf(fmt, ##args)
123 
124 #ifdef __cplusplus
125 #if __cplusplus
126 }
127 #endif /* __cplusplus */
128 #endif /* __cplusplus */
129 
130 #endif /* _LOS_PRINTF_H */
131