1 Star 1 Fork 0

OpenNuvoton/NuTool-USB-to-Serial-Port

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Logger.cpp 723 Bytes
一键复制 编辑 原始数据 按行查看 历史
ccma 提交于 2020-05-20 17:58 +08:00 . NuBridge2 terminal preliminary version
#include "Logger.h"
Logger::Logger(QObject *parent, QString fileName) : QObject(parent)
{
m_showDate = true;
if (!fileName.isEmpty()) {
file = new QFile;
file->setFileName(fileName);
file->open(QIODevice::Append | QIODevice::Text);
}
}
void Logger::write(const QString &value)
{
QString text = value;// + "";
if (m_showDate) {
text = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss ") + text;
}
QTextStream out(file);
out.setCodec("UTF-8");
if (file != 0) {
out << text << endl;
}
}
void Logger::setShowDateTime(bool value)
{
m_showDate = value;
}
Logger::~Logger()
{
if (file != 0) {
file->close();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/OpenNuvoton/NuTool-USB-to-Serial-Port.git
git@gitee.com:OpenNuvoton/NuTool-USB-to-Serial-Port.git
OpenNuvoton
NuTool-USB-to-Serial-Port
NuTool-USB-to-Serial-Port
master

搜索帮助