feature add tag support
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m8s
rpcrypto-build / build (Debug, mipsel-openwrt-linux.toolchain.cmake) (push) Failing after 1m6s
rpcrypto-build / build (Debug, mipsel-openwrt-linux-musl.toolchain.cmake) (push) Failing after 1m10s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 1m6s
linux-x64-gcc / linux-gcc (push) Failing after 1m0s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m8s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m44s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m15s
rpcrypto-build / build (Release, mipsel-openwrt-linux.toolchain.cmake) (push) Failing after 1m34s
rpcrypto-build / build (Release, mipsel-openwrt-linux-musl.toolchain.cmake) (push) Failing after 1m11s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m22s
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m8s
rpcrypto-build / build (Debug, mipsel-openwrt-linux.toolchain.cmake) (push) Failing after 1m6s
rpcrypto-build / build (Debug, mipsel-openwrt-linux-musl.toolchain.cmake) (push) Failing after 1m10s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 1m6s
linux-x64-gcc / linux-gcc (push) Failing after 1m0s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m8s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m44s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m15s
rpcrypto-build / build (Release, mipsel-openwrt-linux.toolchain.cmake) (push) Failing after 1m34s
rpcrypto-build / build (Release, mipsel-openwrt-linux-musl.toolchain.cmake) (push) Failing after 1m11s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m22s
This commit is contained in:
parent
df691c16f1
commit
17126c78db
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
namespace tqcq {
|
namespace tqcq {
|
||||||
|
|
||||||
#define _ULOG(level, fmt_str, ...) \
|
#define _ULOG(level, tag, fmt_str, ...) \
|
||||||
tqcq::Logger::GetInstance().Log(level, __FILE__, __FUNCTION__, __LINE__, \
|
tqcq::Logger::GetInstance().Log(level, __FILE__, __FUNCTION__, __LINE__, tag, \
|
||||||
fmt::format(fmt_str, ##__VA_ARGS__).c_str())
|
fmt::format(fmt_str, ##__VA_ARGS__).c_str())
|
||||||
|
|
||||||
#define ULOG_SET_STRIPPED_PREFIX_LEN(len) ::tqcq::Logger::GetInstance().SetStrippedPrefixLen(len)
|
#define ULOG_SET_STRIPPED_PREFIX_LEN(len) ::tqcq::Logger::GetInstance().SetStrippedPrefixLen(len)
|
||||||
|
@ -22,17 +22,20 @@ Logger::Logger() {}
|
|||||||
Logger::~Logger() {}
|
Logger::~Logger() {}
|
||||||
|
|
||||||
void
|
void
|
||||||
Logger::Log(int32_t level, const char *file, const char *func, int32_t line, const char *msg)
|
Logger::Log(int32_t level, const char *file, const char *func, int32_t line, const char* tag, const char *msg)
|
||||||
{
|
{
|
||||||
const char *level_name = Level::ToString(level);
|
const char *level_name = Level::ToString(level);
|
||||||
std::string pattern = "[{}] {}:{}@{} msg: {}";
|
/**
|
||||||
|
* @brief level_name, file:line@func tag msg
|
||||||
|
*/
|
||||||
|
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, file + stripped_prefix_len_, line, func, msg);
|
fmt::print(pattern, level_name, tag, file + stripped_prefix_len_, line, func, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
Logger();
|
Logger();
|
||||||
~Logger();
|
~Logger();
|
||||||
static Logger &GetInstance();
|
static Logger &GetInstance();
|
||||||
void Log(int32_t level, const char *file, const char *func, int32_t line, const char *msg);
|
void Log(int32_t level, const char *file, const char *func, int32_t line, const char* tag,const char *msg);
|
||||||
void SetStrippedPrefixLen(size_t len);
|
void SetStrippedPrefixLen(size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ulib/log/log.h>
|
#include <ulib/log/log.h>
|
||||||
|
|
||||||
|
static const char* kLogTag = "UnitTest";
|
||||||
|
|
||||||
TEST(ULIB_LOG_TEST, base_test)
|
TEST(ULIB_LOG_TEST, base_test)
|
||||||
{
|
{
|
||||||
ULOG_TRACE("trace log");
|
ULOG_TRACE(kLogTag, "trace log");
|
||||||
ULOG_DEBUG("debug log");
|
ULOG_DEBUG(kLogTag, "debug log");
|
||||||
ULOG_INFO("info log");
|
ULOG_INFO(kLogTag, "info log");
|
||||||
ULOG_WARN("warn log");
|
ULOG_WARN(kLogTag, "warn log");
|
||||||
ULOG_ERROR("error log");
|
ULOG_ERROR(kLogTag, "error log");
|
||||||
ULOG_FATAL("fatal log");
|
ULOG_FATAL(kLogTag, "fatal log");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user