utils.cpp 1.37 KB
Newer Older
Thiago C. Santini's avatar
Thiago C. Santini committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include "utils.h"

QString getTimestampStr()
{
    QTimeZone tz(settings.value("outputTimestamp/tz").toByteArray());
    QString format(settings.value("outputTimestamp/format").toString());
    return QDateTime::currentDateTimeUtc().toTimeZone(tz).toString(format);
}

QString getNamePrefix()
{
    QString base(gCurrentSubjectName);

    if (! gCurrentSubjectName.isEmpty())
        base.append("_");

    base.append(getTimestampStr());

    return base.append("_");
}

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
void logMessages(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    static QMutex logMutex;
    static std::ofstream log;
    QMutexLocker lock(&logMutex);

    if (!log.is_open())
        log.open("EyeRec.log", std::ofstream::app);
    else
        log << qFormatLogMessage(type, context, msg).toStdString() << std::endl;

    std::cout << qFormatLogMessage(type, context, msg).toStdString() << std::endl;
}

void initBanner()
{
    qDebug() << "\n" << "######################################################################"
             << "\n" << "# " << QDateTime::currentDateTime().toString()
             << "\n" << "######################################################################";
}

void exitBanner()
{
    qDebug() << "[Exiting]" << QDateTime::currentDateTime().toString();
}

GlobalTimer gTimer;

QString gBinaryPath = "";
Thiago C. Santini's avatar
Thiago C. Santini committed
51
QString gCurrentSubjectName = "";
52
QString gFileIndexStr = "0000";