XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
xwlog.c
浏览该文件的文档.
1
13#include <xwos/standard.h>
14#include <stdio.h> // cppcheck-suppress [misra-c2012-21.6]
15#include <xwos/lib/xwlog.h>
16
17extern xwer_t soc_log_write(const char * s, xwsz_t * n);
18extern xwer_t board_log_write(const char * s, xwsz_t * n);
19
31xwer_t xwps(const char * str, xwsz_t size)
32{
33 xwer_t rc;
34#if defined(SOCCFG_LOG) && (1 == SOCCFG_LOG)
35 rc = soc_log_write(str, &size);
36#elif defined(BRDCFG_LOG) && (1 == BRDCFG_LOG)
37 rc = board_log_write(str, &size);
38#else
39 XWOS_UNUSED(str);
40 XWOS_UNUSED(str);
41 rc = -ENOSYS;
42#endif
43 return rc;
44}
45
58int xwpf(const char * fmt, ...)
59{
60 va_list args;
61 xwer_t rc;
62 int i;
63 xwsz_t sz;
64 char buf[XWLIBCFG_XWLOG_BUFSIZE];
65
66 va_start(args, fmt);
67 i = vsnprintf(buf, sizeof(buf), fmt, args);
68 va_end(args);
69 if (i < 0) {
70 goto err_vsnprintf;
71 }
72 sz = (xwsz_t)i;
73
74 /* Print the string */
75#if defined(SOCCFG_LOG) && (1 == SOCCFG_LOG)
76 rc = soc_log_write(buf, &sz);
77 if (rc < 0) {
78 i = (int)rc;
79 } else {
80 i = (int)sz;
81 }
82#elif defined(BRDCFG_LOG) && (1 == BRDCFG_LOG)
83 rc = board_log_write(buf, &sz);
84 if (rc < 0) {
85 i = (int)rc;
86 } else {
87 i = (int)sz;
88 }
89#else
90# warning "Can't find the log configurations!"
91 i = 0;
92#endif
93
94err_vsnprintf:
95 return i;
96}
#define __xwlib_code
Definition compiler.h:199
#define ENOSYS
Function not implemented
Definition errno.h:110
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
#define XWOS_UNUSED(x)
Definition standard.h:66
xwer_t board_log_write(const char *s, xwsz_t *n)
xwer_t soc_log_write(const char *s, xwsz_t *n)
XWOS通用库:日志
XWOS的标准头文件