console_be.c 766 B

1234567891011121314151617181920212223242526272829303132
  1. #include <stdio.h>
  2. #include <FreeRTOS.h>
  3. #include "board.h"
  4. #include "ulog.h"
  5. #ifdef ULOG_BACKEND_USING_CONSOLE
  6. #if defined(ULOG_ASYNC_OUTPUT_BY_THREAD) && ULOG_ASYNC_OUTPUT_THREAD_STACK < 384
  7. #error "The thread stack size must more than 384 when using async output by thread (ULOG_ASYNC_OUTPUT_BY_THREAD)"
  8. #endif
  9. static struct ulog_backend console;
  10. void ulog_console_backend_output(struct ulog_backend *backend, uint32_t level, const char *tag, int is_raw,
  11. const char *log, size_t len)
  12. {
  13. int i;
  14. for (i = 0; i < len; i++)
  15. putchar(log[i]);
  16. }
  17. int ulog_console_backend_init(void)
  18. {
  19. console.output = ulog_console_backend_output;
  20. ulog_backend_register(&console, "console", pdFALSE);
  21. return 0;
  22. }
  23. #endif /* ULOG_BACKEND_USING_CONSOLE */