Files
logging/include/logging.h
youmetme d0bfc31563 Dev (#11)
* #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偏移单位
2024-11-20 11:56:47 +08:00

57 lines
1.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef __LOGGING_H__
#define __LOGGING_H__
#include <stdarg.h>
#include <stdbool.h>
#include "logging/logging-core.h"
#include "logging/logging-handler.h"
#include "logging/logging-interceptor.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Logger {
log_level level;
log_Handler *handler;
log_Interceptor *interceptor;
const char *name;
void (*fatal)(const char *format, ...);
void (*error)(const char *format, ...);
void (*warning)(const char *format, ...);
void (*info)(const char *format, ...);
void (*debug)(const char *format, ...);
bool (*addHandler)(log_Handler *handler);
bool (*addInterceptor)(log_Interceptor *Interceptor);
} Logger;
/**
* @brief 创建日志对象,日志对象为单例模式后续可通过getDefaultLogger方法获取
重复调用该方法不会创建新的日志对象,只会返回默认日志对象,并且会修改默认日志对象的名称和等级
* @param name 日志名称
* @param level 日志等级
* @return Logger* 日志对象指针
*/
Logger *newLogger(const char *name, log_level level);
/**
* @brief 设置日志等级
* @param logger 日志对象
* @param level 日志等级
*/
log_status setLevel(Logger *logger, log_level level);
/**
* @brief 获取默认日志对象
*/
Logger *getDefaultLogger(void);
/**
* @brief 销毁日志对象,该方法会销毁默认日志对象
*/
log_status destroyLogger(void);
#ifdef __cplusplus
}
#endif
#endif // __LOGGING_H__