1. 前言
Qt 实现的日志函数, 可以按照日期年月日路径生成文件并记录日志
2. 效果
3. 源码
main.cpp
#include <QCoreApplication>
#include <QMutex>
#include <QString>
#include <QDir>
#include <QFile>
#include <QTextStream>
#include <QDateTime>
QMutex LogLock;
int WriteLog(QString type, QString content)
{
LogLock.lock();
QDateTime currentTime = QDateTime::currentDateTime();
QString time = currentTime.toString("yyyy-MM-dd hh:mm:ss");
QString date= currentTime.toString("yyyyMMdd");
QString month = date.mid(4, 2);
QString year=date.mid(0, 4);
QString day =