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
32int xwpf(const char * fmt, ...)
33{
34 va_list args;
35 xwer_t rc;
36 int i;
37 xwsz_t sz;
38 char buf[XWLIBCFG_XWLOG_BUFSIZE];
39
40 va_start(args, fmt);
41 i = vsnprintf(buf, sizeof(buf), fmt, args);
42 va_end(args);
43 if (i < 0) {
44 goto err_vsnprintf;
45 }
46 sz = (xwsz_t)i;
47
48 /* Print the string */
49#if defined(SOCCFG_LOG) && (1 == SOCCFG_LOG)
50 rc = soc_log_write(buf, &sz);
51 if (rc < 0) {
52 i = (int)rc;
53 } else {
54 i = (int)sz;
55 }
56#elif defined(BRDCFG_LOG) && (1 == BRDCFG_LOG)
57 rc = board_log_write(buf, &sz);
58 if (rc < 0) {
59 i = (int)rc;
60 } else {
61 i = (int)sz;
62 }
63#else
64# warning "Can't find the log configurations!"
65 i = 0;
66#endif
67
68err_vsnprintf:
69 return i;
70}
#define __xwlib_code
Definition compiler.h:199
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:32
xwer_t board_log_write(const char *s, xwsz_t *n)
xwer_t soc_log_write(const char *s, xwsz_t *n)
XWOS通用库:日志
XWOS的标准头文件