kopia lustrzana https://gitlab.com/eliggett/wfview
Use date/time for log name if none specified
rodzic
3ee237e736
commit
26510c4166
|
@ -1,7 +1,8 @@
|
||||||
#include "loggingwindow.h"
|
#include "loggingwindow.h"
|
||||||
#include "ui_loggingwindow.h"
|
#include "ui_loggingwindow.h"
|
||||||
|
|
||||||
loggingWindow::loggingWindow(QWidget *parent) :
|
loggingWindow::loggingWindow(QString logFile, QWidget *parent) :
|
||||||
|
logFilename(logFile),
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::loggingWindow)
|
ui(new Ui::loggingWindow)
|
||||||
{
|
{
|
||||||
|
@ -12,20 +13,15 @@ loggingWindow::loggingWindow(QWidget *parent) :
|
||||||
ui->annotateBtn->setDefault(true);
|
ui->annotateBtn->setDefault(true);
|
||||||
ui->logTextDisplay->setFocusPolicy(Qt::NoFocus);
|
ui->logTextDisplay->setFocusPolicy(Qt::NoFocus);
|
||||||
ui->annotateBtn->setFocusPolicy(Qt::NoFocus);
|
ui->annotateBtn->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
|
QDir d = QFileInfo(logFilename).absoluteDir();
|
||||||
|
logDirectory = d.absolutePath();
|
||||||
|
|
||||||
QFont font("Monospace");
|
QFont font("Monospace");
|
||||||
font.setStyleHint(QFont::TypeWriter);
|
font.setStyleHint(QFont::TypeWriter);
|
||||||
ui->logTextDisplay->setFont(font);
|
ui->logTextDisplay->setFont(font);
|
||||||
ui->userAnnotationText->setFont(font);
|
ui->userAnnotationText->setFont(font);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
logFilename = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation)[0] + "/wfview.log";
|
|
||||||
logDirectory = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation)[0];
|
|
||||||
|
|
||||||
#else
|
|
||||||
logFilename= QStandardPaths::standardLocations(QStandardPaths::TempLocation)[0] + "/wfview.log";
|
|
||||||
logDirectory = QStandardPaths::standardLocations(QStandardPaths::TempLocation)[0];
|
|
||||||
#endif
|
|
||||||
clipboard = QApplication::clipboard();
|
clipboard = QApplication::clipboard();
|
||||||
socket = new QTcpSocket(this);
|
socket = new QTcpSocket(this);
|
||||||
connect(socket, SIGNAL(connected()), this, SLOT(connectedToHost()));
|
connect(socket, SIGNAL(connected()), this, SLOT(connectedToHost()));
|
||||||
|
@ -157,7 +153,7 @@ void loggingWindow::on_openDirBtn_clicked()
|
||||||
#endif
|
#endif
|
||||||
arg += QDir::toNativeSeparators(dir.canonicalFilePath());;
|
arg += QDir::toNativeSeparators(dir.canonicalFilePath());;
|
||||||
rtn = QProcess::startDetached(cmd, arg);
|
rtn = QProcess::startDetached(cmd, arg);
|
||||||
if(!rtn)
|
if(rtn)
|
||||||
qInfo(logLogger()) << "Error, open log directory" << logDirectory << "command failed";
|
qInfo(logLogger()) << "Error, open log directory" << logDirectory << "command failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class loggingWindow : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit loggingWindow(QWidget *parent = nullptr);
|
explicit loggingWindow(QString logFile, QWidget *parent = NULL);
|
||||||
~loggingWindow();
|
~loggingWindow();
|
||||||
void acceptLogText(QString text);
|
void acceptLogText(QString text);
|
||||||
|
|
||||||
|
|
10
main.cpp
10
main.cpp
|
@ -74,10 +74,12 @@ int main(int argc, char *argv[])
|
||||||
QString serialPortCL;
|
QString serialPortCL;
|
||||||
QString hostCL;
|
QString hostCL;
|
||||||
QString civCL;
|
QString civCL;
|
||||||
|
QDateTime date = QDateTime::currentDateTime();
|
||||||
|
QString formattedTime = date.toString("dd.MM.yyyy hh:mm:ss");
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QString logFilename= QStandardPaths::standardLocations(QStandardPaths::DownloadLocation)[0] + "/wfview.log";
|
QString logFilename = (QString("%1/%2-%3.log").arg(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation)[0]).arg(a.applicationName()).arg(date.toString("yyyyMMddhhmmss")));
|
||||||
#else
|
#else
|
||||||
QString logFilename= QStandardPaths::standardLocations(QStandardPaths::TempLocation)[0] + "/wfview.log";
|
QString logFilename = (QString("%1/%2-%3.log").arg(QStandardPaths::standardLocations(QStandardPaths::TempLocation)[0]).arg(a.applicationName()).arg(date.toString("yyyyMMddhhmmss")));
|
||||||
#endif
|
#endif
|
||||||
QString settingsFile = NULL;
|
QString settingsFile = NULL;
|
||||||
QString currentArg;
|
QString currentArg;
|
||||||
|
@ -185,10 +187,10 @@ int main(int argc, char *argv[])
|
||||||
signal(SIGTERM, cleanup);
|
signal(SIGTERM, cleanup);
|
||||||
signal(SIGKILL, cleanup);
|
signal(SIGKILL, cleanup);
|
||||||
#endif
|
#endif
|
||||||
w = new servermain(serialPortCL, hostCL, settingsFile);
|
w = new servermain(serialPortCL, hostCL, logFilename, settingsFile);
|
||||||
#else
|
#else
|
||||||
a.setWheelScrollLines(1); // one line per wheel click
|
a.setWheelScrollLines(1); // one line per wheel click
|
||||||
wfmain w(serialPortCL, hostCL, settingsFile, debugMode);
|
wfmain w(serialPortCL, hostCL, settingsFile, logFilename, debugMode);
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// This code is copyright 2017-2020 Elliott H. Liggett
|
// This code is copyright 2017-2020 Elliott H. Liggett
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
servermain::servermain(const QString serialPortCL, const QString hostCL, const QString settingsFile)
|
servermain::servermain(const QString serialPortCL, const QString hostCL, const QString settingsFile, const QString logFile)
|
||||||
{
|
{
|
||||||
this->serialPortCL = serialPortCL;
|
this->serialPortCL = serialPortCL;
|
||||||
this->hostCL = hostCL;
|
this->hostCL = hostCL;
|
||||||
|
|
|
@ -46,7 +46,7 @@ class servermain : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
servermain(const QString serialPortCL, const QString hostCL, const QString settingsFile);
|
servermain(const QString serialPortCL, const QString hostCL, const QString logFile, const QString settingsFile);
|
||||||
QString serialPortCL;
|
QString serialPortCL;
|
||||||
QString hostCL;
|
QString hostCL;
|
||||||
~servermain();
|
~servermain();
|
||||||
|
|
10
wfmain.cpp
10
wfmain.cpp
|
@ -20,7 +20,8 @@ bool debugModeLogging = true;
|
||||||
bool debugModeLogging = false;
|
bool debugModeLogging = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString settingsFile, bool debugMode, QWidget *parent ) :
|
wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString settingsFile, const QString logFile, bool debugMode, QWidget *parent ) :
|
||||||
|
logFilename(logFile),
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::wfmain)
|
ui(new Ui::wfmain)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s
|
||||||
|
|
||||||
setWindowTitle(QString("wfview"));
|
setWindowTitle(QString("wfview"));
|
||||||
|
|
||||||
logWindow = new loggingWindow();
|
logWindow = new loggingWindow(logFile);
|
||||||
initLogging();
|
initLogging();
|
||||||
logWindow->setInitialDebugState(debugMode);
|
logWindow->setInitialDebugState(debugMode);
|
||||||
qInfo(logSystem()) << version;
|
qInfo(logSystem()) << version;
|
||||||
|
@ -7091,11 +7092,6 @@ void wfmain::on_showLogBtn_clicked()
|
||||||
|
|
||||||
void wfmain::initLogging()
|
void wfmain::initLogging()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
logFilename= QStandardPaths::standardLocations(QStandardPaths::DownloadLocation)[0] + "/wfview.log";
|
|
||||||
#else
|
|
||||||
logFilename= QStandardPaths::standardLocations(QStandardPaths::TempLocation)[0] + "/wfview.log";
|
|
||||||
#endif
|
|
||||||
// Set the logging file before doing anything else.
|
// Set the logging file before doing anything else.
|
||||||
m_logFile.reset(new QFile(logFilename));
|
m_logFile.reset(new QFile(logFilename));
|
||||||
// Open the file logging
|
// Open the file logging
|
||||||
|
|
2
wfmain.h
2
wfmain.h
|
@ -64,7 +64,7 @@ class wfmain : public QMainWindow
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit wfmain(const QString serialPortCL, const QString hostCL, const QString settingsFile, bool debugMode, QWidget *parent = 0);
|
explicit wfmain(const QString serialPortCL, const QString hostCL, const QString settingsFile, const QString logFile, bool debugMode, QWidget *parent = 0);
|
||||||
QString serialPortCL;
|
QString serialPortCL;
|
||||||
QString hostCL;
|
QString hostCL;
|
||||||
~wfmain();
|
~wfmain();
|
||||||
|
|
Ładowanie…
Reference in New Issue