From ad7468931049ffcfe12f3fc2e9c4317b64171524 Mon Sep 17 00:00:00 2001 From: Coldwings Date: Thu, 22 Feb 2024 16:22:29 +0800 Subject: [PATCH] Fix: make_named_tuple maked ref to temporary alogstring Signed-off-by: Coldwings --- common/alog.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/common/alog.h b/common/alog.h index f019ba86..c3a7de17 100644 --- a/common/alog.h +++ b/common/alog.h @@ -528,24 +528,18 @@ inline NamedValue make_named_value(const char (&name)[N], T&& value) } template -inline NamedValue make_named_value(const char (&name)[N], - char (&value)[M]) { - return {ALogStringL(name), alog_forwarding(value)}; +inline NamedValue make_named_value(const char (&name)[N], + char (&value)[M]) { + return {ALogStringL(name), value}; } #define VALUE(x) make_named_value(#x, x) -template -inline LogBuffer& operator << (LogBuffer& log, const NamedValue& v) -{ +template +inline LogBuffer& operator<<(LogBuffer& log, const NamedValue& v) { return log.printf('[', v.name, '=', v.value, ']'); } -inline LogBuffer& operator << (LogBuffer& log, const NamedValue& v) -{ - return log.printf('[', v.name, '=', '"', v.value, '"', ']'); -} - // output a log message, set errno, then return a value // keep errno unchaged if new_errno == 0 #define LOG_ERROR_RETURN(new_errno, retv, ...) { \