console_be.c 978 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <rthw.h>
  11. #include <ulog.h>
  12. #ifdef ULOG_BACKEND_USING_CONSOLE
  13. #if defined(ULOG_ASYNC_OUTPUT_BY_THREAD) && ULOG_ASYNC_OUTPUT_THREAD_STACK < 384
  14. #error "The thread stack size must more than 384 when using async output by thread (ULOG_ASYNC_OUTPUT_BY_THREAD)"
  15. #endif
  16. static struct ulog_backend console = { 0 };
  17. void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw,
  18. const char *log, rt_size_t len)
  19. {
  20. rt_kputs(log);
  21. }
  22. int ulog_console_backend_init(void)
  23. {
  24. ulog_init();
  25. console.output = ulog_console_backend_output;
  26. ulog_backend_register(&console, "console", RT_TRUE);
  27. return 0;
  28. }
  29. INIT_PREV_EXPORT(ulog_console_backend_init);
  30. #endif /* ULOG_BACKEND_USING_CONSOLE */