Added timestamp in log #4845
This commit is contained in:
parent
23739f8484
commit
260a7337d3
|
@ -370,18 +370,18 @@ void MainWindow::updateFound(const QString &version)
|
|||
|
||||
void MainWindow::appendLogInfo(const QString& text)
|
||||
{
|
||||
appendLogRaw("INFO: " + text);
|
||||
appendLogRaw(getTimeStamp() + " INFO: " + text);
|
||||
}
|
||||
|
||||
void MainWindow::appendLogDebug(const QString& text) {
|
||||
if (appConfig().logLevel() >= 1) {
|
||||
appendLogRaw("DEBUG: " + text);
|
||||
appendLogRaw(getTimeStamp() + " DEBUG: " + text);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::appendLogError(const QString& text)
|
||||
{
|
||||
appendLogRaw("ERROR: " + text);
|
||||
appendLogRaw(getTimeStamp() + " ERROR: " + text);
|
||||
}
|
||||
|
||||
void MainWindow::appendLogRaw(const QString& text)
|
||||
|
@ -492,6 +492,12 @@ bool MainWindow::autoHide()
|
|||
return false;
|
||||
}
|
||||
|
||||
QString MainWindow::getTimeStamp()
|
||||
{
|
||||
QDateTime current = QDateTime::currentDateTime();
|
||||
return '[' + current.toString(Qt::ISODate) + ']';
|
||||
}
|
||||
|
||||
void MainWindow::clearLog()
|
||||
{
|
||||
m_pLogOutput->clear();
|
||||
|
|
|
@ -174,6 +174,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
|||
void checkFingerprint(const QString& line);
|
||||
void checkTransmission(const QString& line);
|
||||
bool autoHide();
|
||||
QString getTimeStamp();
|
||||
|
||||
private:
|
||||
QSettings& m_Settings;
|
||||
|
|
|
@ -174,16 +174,17 @@ Log::print(const char* file, int line, const char* fmt, ...)
|
|||
|
||||
char message[kLogMessageLength];
|
||||
|
||||
#ifndef NDEBUG
|
||||
struct tm *tm;
|
||||
char tmp[220];
|
||||
time_t t;
|
||||
time(&t);
|
||||
tm = localtime(&t);
|
||||
sprintf(tmp, "%04i-%02i-%02iT%02i:%02i:%02i", tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
sprintf(message, "%s %s: %s\n\t%s,%d", tmp, g_priority[priority], buffer, file, line);
|
||||
|
||||
#ifndef NDEBUG
|
||||
sprintf(message, "[%s] %s: %s\n\t%s,%d", tmp, g_priority[priority], buffer, file, line);
|
||||
#else
|
||||
sprintf(message, "%s: %s", g_priority[priority], buffer);
|
||||
sprintf(message, "[%s] %s: %s", tmp, g_priority[priority], buffer);
|
||||
#endif
|
||||
|
||||
output(priority, message);
|
||||
|
|
Loading…
Reference in New Issue