XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
xwlog.h
浏览该文件的文档.
1
13#ifndef __xwos_lib_xwlog_h__
14#define __xwos_lib_xwlog_h__
15
16#include <xwos/standard.h>
17
18#if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
19# include <xwos/osal/skd.h>
20#endif
21
28int xwpf(const char * fmt, ...);
29xwer_t xwps(const char * str, xwsz_t size);
30
31#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 0)
32# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
33# define XWLOGF_VERBOSE(tag, fmt, ...) xwpf("C%d|V|" tag " " fmt, \
34 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
35# define XWLOGF_V(tag, fmt, ...) xwpf("C%d|V|" tag " " fmt, \
36 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
37# else
38# define XWLOGF_VERBOSE(tag, fmt, ...) xwpf("V|" tag " " fmt, ##__VA_ARGS__)
39# define XWLOGF_V(tag, fmt, ...) xwpf("V|" tag " " fmt, ##__VA_ARGS__)
40# endif
41#else
42# define XWLOGF_VERBOSE(tag, fmt, ...)
43# define XWLOGF_V(tag, fmt, ...)
44#endif
45
46#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 1)
47# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
48# define XWLOGF_DEBUG(tag, fmt, ...) xwpf("C%d|D|" tag " " fmt, \
49 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
50# define XWLOGF_D(tag, fmt, ...) xwpf("C%d|D|" tag " " fmt, \
51 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
52# else
53# define XWLOGF_DEBUG(tag, fmt, ...) xwpf("D|" tag " " fmt, ##__VA_ARGS__)
54# define XWLOGF_D(tag, fmt, ...) xwpf("D|" tag " " fmt, ##__VA_ARGS__)
55# endif
56#else
57# define XWLOGF_DEBUG(tag, fmt, ...)
58# define XWLOGF_D(tag, fmt, ...)
59#endif
60
61#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 2)
62# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
63# define XWLOGF_INFO(tag, fmt, ...) xwpf("C%d|I|" tag " " fmt, \
64 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
65# define XWLOGF_I(tag, fmt, ...) xwpf("C%d|I|" tag " " fmt, \
66 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
67# else
68# define XWLOGF_INFO(tag, fmt, ...) xwpf("I|" tag " " fmt, ##__VA_ARGS__)
69# define XWLOGF_I(tag, fmt, ...) xwpf("I|" tag " " fmt, ##__VA_ARGS__)
70# endif
71#else
72# define XWLOGF_INFO(tag, fmt, ...)
73# define XWLOGF_I(tag, fmt, ...)
74#endif
75
76#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 3)
77# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
78# define XWLOGF_NOTICE(tag, fmt, ...) xwpf("C%d|N|" tag " " fmt, \
79 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
80# define XWLOGF_N(tag, fmt, ...) xwpf("C%d|N|" tag " " fmt, \
81 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
82# else
83# define XWLOGF_NOTICE(tag, fmt, ...) xwpf("N|" tag " " fmt, ##__VA_ARGS__)
84# define XWLOGF_N(tag, fmt, ...) xwpf("N|" tag " " fmt, ##__VA_ARGS__)
85# endif
86#else
87# define XWLOGF_NOTICE(tag, fmt, ...)
88# define XWLOGF_N(tag, fmt, ...)
89#endif
90
91#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 4)
92# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
93# define XWLOGF_WARNING(tag, fmt, ...) xwpf("C%d|W|" tag " " fmt, \
94 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
95# define XWLOGF_W(tag, fmt, ...) xwpf("C%d|W|" tag " " fmt, \
96 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
97# else
98# define XWLOGF_WARNING(tag, fmt, ...) xwpf("W|" tag " " fmt, ##__VA_ARGS__)
99# define XWLOGF_W(tag, fmt, ...) xwpf("W|" tag " " fmt, ##__VA_ARGS__)
100# endif
101#else
102# define XWLOGF_WARNING(tag, fmt, ...)
103# define XWLOGF_W(tag, fmt, ...)
104#endif
105
106#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 5)
107# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
108# define XWLOGF_ERR(tag, fmt, ...) xwpf("C%d|E|" tag " " fmt, \
109 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
110# define XWLOGF_E(tag, fmt, ...) xwpf("C%d|E|" tag " " fmt, \
111 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
112# else
113# define XWLOGF_ERR(tag, fmt, ...) xwpf("E|" tag " " fmt, ##__VA_ARGS__)
114# define XWLOGF_E(tag, fmt, ...) xwpf("E|" tag " " fmt, ##__VA_ARGS__)
115# endif
116#else
117# define XWLOGF_ERR(tag, fmt, ...)
118# define XWLOGF_E(tag, fmt, ...)
119#endif
120
121#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 6)
122# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
123# define XWLOGF_CRIT(tag, fmt, ...) xwpf("C%d|C|" tag " " fmt, \
124 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
125# define XWLOGF_C(tag, fmt, ...) xwpf("C%d|C|" tag " " fmt, \
126 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
127# else
128# define XWLOGF_CRIT(tag, fmt, ...) xwpf("C|" tag " " fmt, ##__VA_ARGS__)
129# define XWLOGF_C(tag, fmt, ...) xwpf("C|" tag " " fmt, ##__VA_ARGS__)
130# endif
131#else
132# define XWLOGF_CRIT(tag, fmt, ...)
133# define XWLOGF_C(tag, fmt, ...)
134#endif
135
136#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 7)
137# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
138# define XWLOGF_ALERT(tag, fmt, ...) xwpf("C%d|A|" tag " " fmt, \
139 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
140# define XWLOGF_A(tag, fmt, ...) xwpf("C%d|A|" tag " " fmt, \
141 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
142# else
143# define XWLOGF_ALERT(tag, fmt, ...) xwpf("A|" tag " " fmt, ##__VA_ARGS__)
144# define XWLOGF_A(tag, fmt, ...) xwpf("A|" tag " " fmt, ##__VA_ARGS__)
145# endif
146#else
147# define XWLOGF_ALERT(tag, fmt, ...)
148# define XWLOGF_A(tag, fmt, ...)
149#endif
150
151#if defined(XWLIBCFG_LOG) && (1 == XWLIBCFG_LOG) && (XWLIBCFG_XWLOG_LEVEL <= 8)
152# if defined(CPUCFG_CPU_NUM) && (CPUCFG_CPU_NUM > 1)
153# define XWLOGF_EMERG(tag, fmt, ...) xwpf("C%d|G|" tag " " fmt, \
154 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
155# define XWLOGF_G(tag, fmt, ...) xwpf("C%d|G|" tag " " fmt, \
156 xwos_skd_get_cpuid_lc(), ##__VA_ARGS__)
157# else
158# define XWLOGF_EMERG(tag, fmt, ...) xwpf("G|" tag " " fmt, ##__VA_ARGS__)
159# define XWLOGF_G(tag, fmt, ...) xwpf("G|" tag " " fmt, ##__VA_ARGS__)
160# endif
161#else
162# define XWLOGF_EMERG(tag, fmt, ...)
163# define XWLOGF_G(tag, fmt, ...)
164#endif
165
187#define xwlogf(lv, tag, fmt, ...) XWLOGF_##lv(tag, fmt, ##__VA_ARGS__)
188
193#endif /* xwos/lib/xwlog.h */
signed long xwer_t
Definition type.h:554
unsigned long xwsz_t
Definition type.h:339
int xwpf(const char *fmt,...)
格式化字符串并输出到日志,同 printf() 函数
Definition xwlog.c:58
xwer_t xwps(const char *str, xwsz_t size)
输出字符串
Definition xwlog.c:31
操作系统抽象层:调度器
XWOS的标准头文件