mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 19:18:53 +08:00
30 lines
647 B
C++
30 lines
647 B
C++
#include "tkc/str.h"
|
|
#include "tkc/log.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
static ret_t debugger_log(void* ctx, log_level_t level, const char* msg) {
|
|
str_t* str = (str_t*)ctx;
|
|
str_append_more(str, msg, ";", NULL);
|
|
|
|
return RET_OK;
|
|
}
|
|
|
|
TEST(Log, basic) {
|
|
str_t str;
|
|
str_init(&str, 100);
|
|
log_set_hook(debugger_log, &str);
|
|
log_set_hook(debugger_log, &str);
|
|
|
|
log_debug("%d:%s\n", 1, "debug");
|
|
log_info("%d:%s\n", 2, "info");
|
|
log_warn("%d:%s\n", 3, "warn");
|
|
log_error("%d:%s\n", 4, "error");
|
|
|
|
ASSERT_STREQ(str.str, "1:debug\n;2:info\n;3:warn\n;4:error\n;");
|
|
|
|
log_set_hook(NULL, NULL);
|
|
log_set_hook(NULL, NULL);
|
|
|
|
str_reset(&str);
|
|
}
|