Files
logging/tests/test_interceptor.c
youmetme 56e1ac52ff fix 拦截器level参数无效 (#15)
* #feat 增强Fatal级别的底色,修改logging类的方法

* 更新版本号

* 加入test脚本

* fix:conanfile

* test action

* 修复错别字

* add test on windows action

* fix test on windows action

* fix action on windows

* fix

* fix 内存分配错误

* fix msvc 不支持中文注释,删除中文注释

* test on windows and test  chinese char

* ersion 0.2.4

* feature:根据文件大小分割日志

* fix:内存泄露

* fix:使用char偏移单位

* add english brief

* 修改api函数名,加入Default关键字,减除歧义

* Multiple substring interceptors

* 更新版本号

* #fix 拦截器对level参数无效

* fix
2024-11-21 16:02:40 +08:00

48 lines
1.2 KiB
C

#include "logging.h"
#include "logging/logging-core.h"
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
int main() {
Logger *logger = newDefaultLogger("testLogger", LOG_DEBUG);
log_info("This is an info message");
log_error("This is an error message%s", "123");
log_fatal("This is an fatal message");
log_debug("This is a debug message");
log_warning("This is a warning message%s", "123");
char *test1[] = {"This", NULL};
log_Interceptor *tint = loggingSubStringInterceptor(
test1,
LOG_DEBUG,
loggingFileHandler("test_interceptor", 1024 * 1024),
false);
logger->addInterceptor(tint);
char *test2[] = {"123", NULL};
log_Interceptor *tint1 = loggingSubStringInterceptor(
test2,
LOG_ERROR,
loggingFileHandler("test_interceptor1", 1024 * 1024),
true);
logger->addInterceptor(tint1);
printf("\n");
printf("Interceptor added\n");
printf("\n");
log_info("This is an info message");
log_error("This is an error message%s", "123");
log_fatal("This is an fatal message");
log_debug("This is a debug message");
log_warning("This is a warning message%s", "123");
destroyDefaultLogger();
return 0;
}