-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[日志异步处理模块重构与功能增强]: 对
LogAsynchronous
项目进行了一系列重构和功能增强,提升了日志处理的性能和灵活性。
- 引入了`ROLLSIZE`宏定义,明确了日志文件滚动的尺寸为1GB。 - 更新了`kRollPerSeconds_`常量为`g_kRollPerSeconds`,以更清晰地表示每天滚动一次的常量。 - 增加了日志文件名生成的静态函数`getFileName`,支持根据当前时间生成文件名。 - 移除了`FileUtilPrivate`结构体,替换为`FileUtil::FileUtilPrivate`类,增强了封装性。 - 优化了`FileUtil`构造函数,简化了目录生成的逻辑,移除了`autoDelFileDays`参数,改为通过`LogAsync`单例管理。 - 重构了`rollFile`函数,使其更加简洁,并整合了自动删除旧文件的逻辑。 - 更新了`FileUtil`的头文件,移除了一些私有成员函数的声明,因为它们现在是静态函数。 - 对`LogAsync`类进行了扩展,增加了日志路径、自动删除文件和保留天数的设置功能。 - 重构了`LogAsync`的单例实现,使用局部静态变量代替了静态成员变量。 - 增加了对日志输出方向的控制,支持标准输出、文件输出或两者同时。 - 优化了`messageHandler`函数,改进了日志消息的格式化和输出。 - 更新了`main.cpp`和`mainwindow.cpp`,以使用改进后的`LogAsync`功能。
- Loading branch information
Showing
7 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,14 @@ | ||
#include <QApplication> | ||
#include <QElapsedTimer> | ||
#include <QDebug> | ||
|
||
#include "logasync.h" | ||
#include "mainwindow.h" | ||
|
||
auto main(int argc, char *argv[]) -> int | ||
{ | ||
QApplication a(argc, argv); | ||
|
||
LogAsync *log = LogAsync::instance(); | ||
log->setOrientation(LogAsync::Orientation::StdAndFile); | ||
log->setLogLevel(QtDebugMsg); | ||
log->startWork(); | ||
|
||
// QElapsedTimer timer; | ||
// timer.start(); | ||
|
||
// for(int i=0; i< 1000 * 1000; i++){ | ||
// qInfo() << "1234567890qwertyuiopasdfghjklzxcvbnm" << i; | ||
// } | ||
|
||
// qInfo() << timer.elapsed(); | ||
|
||
MainWindow w; | ||
w.show(); | ||
|
||
int result = a.exec(); | ||
log->stop(); | ||
return result; | ||
} |
Oops, something went wrong.