feature update log
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m9s
rpcrypto-build / build (Release, mipsel-openwrt-linux-musl.toolchain.cmake) (push) Failing after 1m9s
linux-x64-gcc / linux-gcc (push) Failing after 55s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 1m0s
rpcrypto-build / build (Debug, mipsel-openwrt-linux-musl.toolchain.cmake) (push) Failing after 1m23s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m34s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m44s
rpcrypto-build / build (Debug, mipsel-openwrt-linux.toolchain.cmake) (push) Failing after 1m44s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m18s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m37s
rpcrypto-build / build (Release, mipsel-openwrt-linux.toolchain.cmake) (push) Failing after 1m59s

This commit is contained in:
tqcq 2023-12-11 15:18:55 +08:00
parent 17126c78db
commit aeec5ebd92

View File

@ -3,7 +3,8 @@
// //
#include "logger.h" #include "logger.h"
#include "fmt/format.h" #include <fmt/format.h>
#include <fmt/time.h>
#include <sstream> #include <sstream>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
@ -26,16 +27,16 @@ Logger::Log(int32_t level, const char *file, const char *func, int32_t line, con
{ {
const char *level_name = Level::ToString(level); const char *level_name = Level::ToString(level);
/** /**
* @brief level_name, file:line@func tag msg * @brief time file:line@func tag level_name msg
*/ */
std::string pattern = "[{:<5}] {} {}:{}@{} {}"; std::string pattern = "{} {}:{}@{} {} [{:<5}]: {}";
// auto add CR // auto add CR
bool need_append_line_break = !msg || *msg == '\0' || msg[strlen(msg) - 1] != '\n'; bool need_append_line_break = !msg || *msg == '\0' || msg[strlen(msg) - 1] != '\n';
if (need_append_line_break) { if (need_append_line_break) {
pattern.append(1, '\n'); pattern.append(1, '\n');
} }
fmt::print(pattern, level_name, tag, file + stripped_prefix_len_, line, func, msg); fmt::print(pattern, "", file + stripped_prefix_len_, line, func, tag, level_name, msg);
} }
void void