diff --git a/src/logger.cpp b/src/logger.cpp new file mode 100644 index 0000000..2572922 --- /dev/null +++ b/src/logger.cpp @@ -0,0 +1,26 @@ +#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); + } + write("=========Startup=========="); +} + +void Logger::write(const QString &value) { + QString text = value;// + ""; + text = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss ") + text; + QTextStream out(file); + out.setCodec("UTF-8"); + if (file != 0) { + out << text << endl; + } +} + +Logger::~Logger() { + if (file != 0) + file->close(); +} \ No newline at end of file diff --git a/src/logger.h b/src/logger.h new file mode 100644 index 0000000..a37930d --- /dev/null +++ b/src/logger.h @@ -0,0 +1,23 @@ +#ifndef LOGGER_H +#define LOGGER_H + +#include "precompiled.h" + +class Logger : public QObject +{ + Q_OBJECT +public: + explicit Logger(QObject *parent, QString fileName); + ~Logger(); + +private: + QFile *file; + bool m_showDate; + +signals: + +public slots: + void write(const QString &value); +}; + +#endif // LOGGER_H \ No newline at end of file diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index fb48726..40a0f9d 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -49,7 +49,8 @@ SOURCES += \ src/qrcodelabel.cpp \ src/connection.cpp \ src/fillediconlabel.cpp \ - src/addressbook.cpp + src/addressbook.cpp \ + src/logger.cpp HEADERS += \ src/mainwindow.h \ @@ -67,7 +68,8 @@ HEADERS += \ src/qrcodelabel.h \ src/connection.h \ src/fillediconlabel.h \ - src/addressbook.h + src/addressbook.h \ + src/logger.h FORMS += \ src/mainwindow.ui \