diff options
| author | guozhanxin <[email protected]> | 2022-02-09 15:18:26 +0800 |
|---|---|---|
| committer | guo <[email protected]> | 2022-02-10 10:22:08 +0800 |
| commit | 26c511475efd619de79c57637f178bbc758cc420 (patch) | |
| tree | 63a2783614a9a507b359d210e2706e05caa477a6 | |
| parent | 23c1fdd7790a1e666403d5aaebdc67cafe4c8192 (diff) | |
[ulog] Fixed the problem of abnormal log output at the INIT_BOARD_EXPORT level.
| -rw-r--r-- | components/utilities/ulog/ulog.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index fb268abf35..a0bcd8ca2a 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -190,8 +190,8 @@ static void output_unlock(void) if (!ulog.output_lock_enabled) return; - /* is in thread context */ - if (rt_interrupt_get_nest() == 0) + /* If the scheduler is started and in thread context */ + if (rt_thread_self() && (rt_interrupt_get_nest() == 0)) { rt_sem_release(&ulog.output_locker); } @@ -208,8 +208,8 @@ static void output_lock(void) if (!ulog.output_lock_enabled) return; - /* is in thread context */ - if (rt_interrupt_get_nest() == 0) + /* If the scheduler is started and in thread context */ + if (rt_thread_self() && (rt_interrupt_get_nest() == 0)) { rt_sem_take(&ulog.output_locker, RT_WAITING_FOREVER); } @@ -429,6 +429,13 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is if (!ulog.init_ok) return; + /* if there is no backend */ + if (!rt_slist_first(&ulog.backend_list)) + { + rt_kputs(log); + return; + } + /* output for all backends */ for (node = rt_slist_first(&ulog.backend_list); node; node = rt_slist_next(node)) { |
