summaryrefslogtreecommitdiff
path: root/src/format.hpp
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-03-13 19:43:56 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-03-20 23:45:00 +0800
commitb000ae9e41b8699d1c7d6eefa0441ee05c970d25 (patch)
treed8b3a2fb13c39911f992890d177abb00e1069ce9 /src/format.hpp
parent95fe8f6c660a1c3bf91b5ab78f95ef0c35d8990c (diff)
fix: NONEWLINE more explicit
fixes a problem where all of socket wrote response is using NONE fmt(944b18bde52778b32c31dc23f3d90fc17b94794f) so all of them don't have \n
Diffstat (limited to 'src/format.hpp')
-rw-r--r--src/format.hpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/format.hpp b/src/format.hpp
index 42a4458..dd210c0 100644
--- a/src/format.hpp
+++ b/src/format.hpp
@@ -9,6 +9,7 @@ enum eFormatType : int8_t {
WARN,
ERR,
SYS,
+ NONEWLINE
};
namespace NFormatter {
@@ -34,8 +35,10 @@ inline std::string fmt(eFormatType type, std::string str) {
prefix = "";
break;
}
- if (!str.empty() && str.back() != '\n' && !prefix.empty())
+
+ if (str.back() != '\n' && type != NONEWLINE)
str += '\n';
+
return prefix + str;
}