1 /*
2 * Copyright (c) 2006-2022, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2018-09-04 armink the first version
9 */
10
11 #include <rthw.h>
12 #include <ulog.h>
13
14 #ifdef ULOG_BACKEND_USING_CONSOLE
15
16 #if defined(ULOG_ASYNC_OUTPUT_BY_THREAD) && ULOG_ASYNC_OUTPUT_THREAD_STACK < 384
17 #error "The thread stack size must more than 384 when using async output by thread (ULOG_ASYNC_OUTPUT_BY_THREAD)"
18 #endif
19
20 static struct ulog_backend console = { 0 };
21
ulog_console_backend_output(struct ulog_backend * backend,rt_uint32_t level,const char * tag,rt_bool_t is_raw,const char * log,rt_size_t len)22 void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw,
23 const char *log, rt_size_t len)
24 {
25 rt_kputs(log);
26
27 }
28
ulog_console_backend_init(void)29 int ulog_console_backend_init(void)
30 {
31 ulog_init();
32 console.output = ulog_console_backend_output;
33
34 ulog_backend_register(&console, "console", RT_TRUE);
35
36 return 0;
37 }
38 INIT_PREV_EXPORT(ulog_console_backend_init);
39
40 #endif /* ULOG_BACKEND_USING_CONSOLE */
41