mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-16 01:05:15 +08:00
[ulog][rtc][time][bug] solve the interference when enable the ulog timestamp (#5687)
* [ulog] 解决ulog开启时间戳后与libc time以及rtc驱动相关函数干涉的问题 * ulog:当发生递归输出时,后续递归想要输出的内容可能会因为防范递归的判断而无法输出 因此修改输出规则,在发生递归时,采用简单的,无格式的方式直接输出。这样既保证不会发生递归输出,也可以保证递归输出的部分可以正常输出。 * [ulog] size_t->rt_size_t NULL->RT_NULL
This commit is contained in:
1 parent
fba060e550
commit
8b58577230
7 files changed
+97
-81
No files matched your search
@@ -249,7 +249,7 @@ static rt_err_t stm32_rtc_get_secs(void *args)
|
||||
struct timeval tv;
|
||||
get_rtc_timeval(&tv);
|
||||
*(rt_uint32_t *) args = tv.tv_sec;
|
||||
LOG_D("RTC: get rtc_time %x\n", *(rt_uint32_t *)args);
|
||||
LOG_D("RTC: get rtc_time %x", *(rt_uint32_t *)args);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ static rt_err_t stm32_rtc_set_secs(void *args)
|
||||
{
|
||||
result = -RT_ERROR;
|
||||
}
|
||||
LOG_D("RTC: set rtc_time %x\n", *(rt_uint32_t *)args);
|
||||
LOG_D("RTC: set rtc_time %x", *(rt_uint32_t *)args);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -113,16 +113,14 @@ static rt_err_t get_timeval(struct timeval *tv)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */
|
||||
rt_kprintf(_WARNING_NO_RTC);
|
||||
LOG_W(_WARNING_NO_RTC);
|
||||
return -RT_ENOSYS;
|
||||
}
|
||||
|
||||
return rst;
|
||||
|
||||
#else
|
||||
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */
|
||||
rt_kprintf(_WARNING_NO_RTC);
|
||||
LOG_W(_WARNING_NO_RTC);
|
||||
return -RT_ENOSYS;
|
||||
#endif /* RT_USING_RTC */
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -20,7 +20,7 @@
|
||||
static struct ulog_backend console = { 0 };
|
||||
|
||||
void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw,
|
||||
const char *log, size_t len)
|
||||
const char *log, rt_size_t len)
|
||||
{
|
||||
#ifdef RT_USING_DEVICE
|
||||
rt_device_t dev = rt_console_get_device();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -170,7 +170,7 @@ static const char *get_month_str(uint8_t month)
|
||||
|
||||
RT_WEAK rt_size_t syslog_formater(char *log_buf, int level, const char *tag, rt_bool_t newline, const char *format, va_list args)
|
||||
{
|
||||
extern size_t ulog_strcpy(size_t cur_len, char *dst, const char *src);
|
||||
extern rt_size_t ulog_strcpy(rt_size_t cur_len, char *dst, const char *src);
|
||||
|
||||
rt_size_t log_len = 0, newline_len = rt_strlen(ULOG_NEWLINE_SIGN);
|
||||
int fmt_result;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -18,8 +18,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ULOG_VERSION_STR "0.1.1"
|
||||
|
||||
/*
|
||||
* ulog init and deint
|
||||
*/
|
||||
@@ -42,12 +40,12 @@ void ulog_deinit(void);
|
||||
* LOG_D("this is a debug log!");
|
||||
* LOG_E("this is a error log!");
|
||||
*/
|
||||
#define LOG_E(...) ulog_e(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_W(...) ulog_w(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_I(...) ulog_i(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_D(...) ulog_d(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_RAW(...) ulog_raw(__VA_ARGS__)
|
||||
#define LOG_HEX(name, width, buf, size) ulog_hex(name, width, buf, size)
|
||||
#define LOG_E(...) ulog_e(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_W(...) ulog_w(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_I(...) ulog_i(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_D(...) ulog_d(LOG_TAG, __VA_ARGS__)
|
||||
#define LOG_RAW(...) ulog_raw(__VA_ARGS__)
|
||||
#define LOG_HEX(name, width, buf, size) ulog_hex(name, width, buf, size)
|
||||
|
||||
/*
|
||||
* backend register and unregister
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -11,9 +11,6 @@
|
||||
#ifndef _ULOG_DEF_H_
|
||||
#define _ULOG_DEF_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <rtdef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -208,15 +205,15 @@ struct ulog_backend
|
||||
rt_bool_t support_color;
|
||||
rt_uint32_t out_level;
|
||||
void (*init) (struct ulog_backend *backend);
|
||||
void (*output)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, size_t len);
|
||||
void (*output)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, rt_size_t len);
|
||||
void (*flush) (struct ulog_backend *backend);
|
||||
void (*deinit)(struct ulog_backend *backend);
|
||||
/* The filter will be call before output. It will return TRUE when the filter condition is math. */
|
||||
rt_bool_t (*filter)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, size_t len);
|
||||
rt_bool_t (*filter)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, rt_size_t len);
|
||||
rt_slist_t list;
|
||||
};
|
||||
typedef struct ulog_backend *ulog_backend_t;
|
||||
typedef rt_bool_t (*ulog_backend_filter_t)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, size_t len);
|
||||
typedef rt_bool_t (*ulog_backend_filter_t)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, rt_size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user