add english brief
This commit is contained in:
108
README.en.md
Normal file
108
README.en.md
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
# C language logging library logging
|
||||||
|
|
||||||
|
## brief
|
||||||
|
|
||||||
|
Logging is a lightweight and easy-to-use C language log library that supports log level, log format, log output, log files, and other functions.
|
||||||
|
|
||||||
|
## function
|
||||||
|
- Support log levels: DEBUG, INFO, Warning, ERROR, FATAL
|
||||||
|
- Support log formats: timestamp, log level, log content
|
||||||
|
- Support log output: console, file
|
||||||
|
- Support log files: automatic creation, automatic scrolling, log segmentation
|
||||||
|
|
||||||
|
## install
|
||||||
|
- Conan
|
||||||
|
```shell
|
||||||
|
conan create .
|
||||||
|
```
|
||||||
|
- cmake
|
||||||
|
```shell
|
||||||
|
```
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
### console log
|
||||||
|
```c
|
||||||
|
#include "logging.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Logger *logger = newLogger("testLogger", LOG_DEBUG);
|
||||||
|
|
||||||
|
logger->info("This is an info message");
|
||||||
|
logger->error("This is an error message%s", "123");
|
||||||
|
logger->fatal("This is an fatal message");
|
||||||
|
logger->debug("This is a debug message");
|
||||||
|
logger->warning("This is a warning message%s", "123");
|
||||||
|
|
||||||
|
destroyLogger();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### file log
|
||||||
|
```c
|
||||||
|
#include "logging.h"
|
||||||
|
#include "logging/logging-handler.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Logger *logger = newLogger("testLogger", LOG_DEBUG);
|
||||||
|
logger->addHandler(loggingFileHandler("test1", 1024*1024));
|
||||||
|
|
||||||
|
logger->info("This is an info message");
|
||||||
|
logger->error("This is an error message%s", "123");
|
||||||
|
logger->fatal("This is an fatal message");
|
||||||
|
logger->debug("This is a debug message");
|
||||||
|
logger->warning("This is a warning message%s", "123");
|
||||||
|
|
||||||
|
destroyLogger();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logging Interceptor
|
||||||
|
> Support adding custom interceptors, currently with built-in substring interceptors
|
||||||
|
> The function of an interceptor is to redirect intercepted logs to the interceptor's dedicated processor
|
||||||
|
|
||||||
|
|
||||||
|
#### example
|
||||||
|
Redirects intercepted logs to a dedicated file processor
|
||||||
|
```c
|
||||||
|
#include "logging.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Logger *logger = newLogger("testLogger", LOG_DEBUG);
|
||||||
|
|
||||||
|
logger->info("This is an info message");
|
||||||
|
logger->error("This is an error message%s", "123");
|
||||||
|
logger->fatal("This is an fatal message");
|
||||||
|
logger->debug("This is a debug message");
|
||||||
|
logger->warning("This is a warning message%s", "123");
|
||||||
|
|
||||||
|
char *test1[] = {"123", "tt"};
|
||||||
|
|
||||||
|
log_Interceptor *tint = loggingSubStringInterceptor(
|
||||||
|
test1,
|
||||||
|
2,
|
||||||
|
LOG_DEBUG,
|
||||||
|
loggingFileHandler("test_interceptor", 1024 * 1024));
|
||||||
|
|
||||||
|
logger->addInterceptor(tint);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
printf("Interceptor added\n");
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
logger->info("This is an info message");
|
||||||
|
logger->error("This is an error message%s", "123");
|
||||||
|
logger->fatal("This is an fatal message");
|
||||||
|
logger->debug("This is a debug message");
|
||||||
|
logger->warning("This is a warning message%s", "123");
|
||||||
|
|
||||||
|
destroyLogger();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# C语言日志库logging
|
# C语言日志库logging
|
||||||
|
|
||||||
|
[English](README.en.md)
|
||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
|
||||||
logging是一个轻量级的简单易用C语言日志库,支持日志级别、日志格式、日志输出、日志文件等功能。
|
logging是一个轻量级的简单易用C语言日志库,支持日志级别、日志格式、日志输出、日志文件等功能。
|
||||||
@@ -9,12 +11,12 @@ logging是一个轻量级的简单易用C语言日志库,支持日志级别、
|
|||||||
- 支持日志级别:DEBUG、INFO、WARN、ERROR、FATAL
|
- 支持日志级别:DEBUG、INFO、WARN、ERROR、FATAL
|
||||||
- 支持日志格式:时间戳、日志级别、日志内容
|
- 支持日志格式:时间戳、日志级别、日志内容
|
||||||
- 支持日志输出:控制台、文件
|
- 支持日志输出:控制台、文件
|
||||||
- 支持日志文件:自动创建、自动滚动、自动删除(未完成)
|
- 支持日志文件:自动创建、自动滚动、日志分割
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
- conan安装使用
|
- conan安装使用
|
||||||
```shell
|
```shell
|
||||||
conan create . --build=missing
|
conan create .
|
||||||
```
|
```
|
||||||
- cmake安装使用
|
- cmake安装使用
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
Reference in New Issue
Block a user