Skip to content

Commit

Permalink
QE: log to file in tmp-dir if logfile not specified explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
fvacek committed Jun 26, 2018
1 parent 4916497 commit 7a09fc4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
3 changes: 1 addition & 2 deletions quickevent/app/quickevent/src/application.cpp
Expand Up @@ -66,6 +66,5 @@ Application *Application::instance(bool must_exist)

QString Application::versionString() const
{
static QString s = QLatin1String("1.2.0");
return s;
return QCoreApplication::applicationVersion();
}
6 changes: 6 additions & 0 deletions quickevent/app/quickevent/src/appversionstring.h
@@ -0,0 +1,6 @@
#ifndef APPVERSIONSTRING_H
#define APPVERSIONSTRING_H

#define APP_VERSION_STRING "2.0.0"

#endif // APPVERSIONSTRING_H
2 changes: 0 additions & 2 deletions quickevent/app/quickevent/src/loggerwidget.cpp
Expand Up @@ -3,8 +3,6 @@

#include <qf/core/model/logtablemodel.h>

static const auto TABLE_MODEL_LOG_DEVICE = QStringLiteral("table_model_log_device");

LoggerWidget::LoggerWidget(QWidget *parent)
: Super(parent)
{
Expand Down
13 changes: 11 additions & 2 deletions quickevent/app/quickevent/src/main.cpp
@@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "application.h"
#include "appversionstring.h"
#include "appclioptions.h"
#include "tablemodellogdevice.h"

Expand All @@ -21,6 +22,7 @@ int main(int argc, char *argv[])
QCoreApplication::setOrganizationName("quickbox");
QCoreApplication::setOrganizationDomain("quickbox.org");
QCoreApplication::setApplicationName("quickevent");
QCoreApplication::setApplicationVersion(APP_VERSION_STRING);

QSettings::setDefaultFormat(QSettings::IniFormat);

Expand All @@ -29,20 +31,27 @@ int main(int argc, char *argv[])
if(argv[i] == QLatin1String("--log-file"))
o_log_file = argv[i + 1];
}
//o_log_file = "c:\\temp\\QE.log";
if(o_log_file.isEmpty())
o_log_file = QDir::tempPath() + "/quickevent.log";

QStringList args = qf::core::LogDevice::setGlobalTresholds(argc, argv);
QScopedPointer<qf::core::FileLogDevice> stderr_log_device(qf::core::FileLogDevice::install());
QScopedPointer<qf::core::FileLogDevice> file_log_device(qf::core::FileLogDevice::install());
file_log_device->setFile(o_log_file);

QScopedPointer<TableModelLogDevice> table_model_log_device(TableModelLogDevice::install());
table_model_log_device->setObjectName("table_model_log_device");
table_model_log_device->setObjectName(TABLE_MODEL_LOG_DEVICE);

qfError() << "QFLog(ERROR) test OK.";// << QVariant::typeToName(QVariant::Int) << QVariant::typeToName(QVariant::String);
qfWarning() << "QFLog(WARNING) test OK.";
qfInfo() << "QFLog(INFO) test OK.";
qfDebug() << "QFLog(DEBUG) test OK.";

qfInfo() << "========================================================";
qfInfo() << QDateTime::currentDateTime().toString(Qt::ISODate) << "starting" << QCoreApplication::applicationName() << "ver:" << QCoreApplication::applicationVersion();
qfInfo() << "Log file:" << o_log_file;
qfInfo() << "========================================================";

quickevent::og::TimeMs::registerQVariantFunctions();
quickevent::si::SiId::registerQVariantFunctions();

Expand Down
3 changes: 2 additions & 1 deletion quickevent/app/quickevent/src/src.pri
Expand Up @@ -12,7 +12,8 @@ HEADERS += \
$$PWD/application.h \
$$PWD/appclioptions.h \
$$PWD/loggerwidget.h \
$$PWD/tablemodellogdevice.h
$$PWD/tablemodellogdevice.h \
$$PWD/appversionstring.h

FORMS +=

Expand Down
2 changes: 2 additions & 0 deletions quickevent/app/quickevent/src/tablemodellogdevice.h
Expand Up @@ -5,6 +5,8 @@

namespace qf { namespace core { namespace model { class LogTableModel; } } }

#define TABLE_MODEL_LOG_DEVICE "table_model_log_device"

class TableModelLogDevice : public qf::core::SignalLogDevice
{
Q_OBJECT
Expand Down

0 comments on commit 7a09fc4

Please sign in to comment.