2025-02-25 16:33:11 +08:00
|
|
|
// custom_printf.h
|
|
|
|
|
#ifndef CUSTOM_PRINTF_H
|
|
|
|
|
#define CUSTOM_PRINTF_H
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdarg.h>
|
2025-02-26 16:39:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2025-02-25 16:33:11 +08:00
|
|
|
#include <list>
|
|
|
|
|
#include <string>
|
|
|
|
|
// 假设这些是你管理输出的列表
|
|
|
|
|
extern std::list<std::string> errorList;
|
|
|
|
|
extern std::list<std::string> warnList;
|
|
|
|
|
extern std::list<std::string> normalList;
|
|
|
|
|
|
|
|
|
|
// 开关
|
|
|
|
|
extern bool errorOutputEnabled;
|
|
|
|
|
extern bool warnOutputEnabled;
|
|
|
|
|
extern bool normalOutputEnabled;
|
|
|
|
|
|
2025-02-26 16:39:10 +08:00
|
|
|
void redirectErrorOutput(bool enabled);
|
|
|
|
|
void redirectWarnOutput(bool enabled);
|
|
|
|
|
void redirectNormalOutput(bool enabled);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
2025-02-25 16:33:11 +08:00
|
|
|
// 自定义的 printf 函数
|
|
|
|
|
int customPrintf(const char* format, ...);
|
2025-02-26 16:39:10 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2025-02-25 16:33:11 +08:00
|
|
|
|
|
|
|
|
// 使用宏将 printf 替换为 customPrintf
|
|
|
|
|
#define printf customPrintf
|
|
|
|
|
|
|
|
|
|
#endif // CUSTOM_PRINTF_H
|