2018-10-30 09:00:30 +08:00
|
|
|
/*
|
2022-03-21 14:06:17 +08:00
|
|
|
* Copyright (c) 2006-2022, RT-Thread Development Team
|
2018-10-30 09:00:30 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2018-09-04 armink the first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <ulog.h>
|
|
|
|
|
|
|
|
#ifdef ULOG_BACKEND_USING_CONSOLE
|
|
|
|
|
|
|
|
#if defined(ULOG_ASYNC_OUTPUT_BY_THREAD) && ULOG_ASYNC_OUTPUT_THREAD_STACK < 384
|
|
|
|
#error "The thread stack size must more than 384 when using async output by thread (ULOG_ASYNC_OUTPUT_BY_THREAD)"
|
|
|
|
#endif
|
|
|
|
|
2021-12-03 12:04:20 +08:00
|
|
|
static struct ulog_backend console = { 0 };
|
2018-10-30 09:00:30 +08:00
|
|
|
|
|
|
|
void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw,
|
2022-03-21 14:06:17 +08:00
|
|
|
const char *log, rt_size_t len)
|
2018-10-30 09:00:30 +08:00
|
|
|
{
|
2024-01-09 20:37:47 +08:00
|
|
|
rt_kputs(log);
|
2018-10-30 09:00:30 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ulog_console_backend_init(void)
|
|
|
|
{
|
2019-01-04 18:57:25 +08:00
|
|
|
ulog_init();
|
2018-10-30 09:00:30 +08:00
|
|
|
console.output = ulog_console_backend_output;
|
|
|
|
|
|
|
|
ulog_backend_register(&console, "console", RT_TRUE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-01-04 18:57:25 +08:00
|
|
|
INIT_PREV_EXPORT(ulog_console_backend_init);
|
2018-10-30 09:00:30 +08:00
|
|
|
|
|
|
|
#endif /* ULOG_BACKEND_USING_CONSOLE */
|