LCOV - code coverage report
Current view: top level - gui/source - logwidget.cpp (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 0 32 0.0 %
Date: 2024-04-21 03:44:01 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Rimco Boudewijns
       2             : // Copyright: see the accompanying file COPYING or copy at
       3             : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING
       4             : //
       5             : // Distributed under the Boost Software License, Version 1.0.
       6             : // (See accompanying file LICENSE_1_0.txt or copy at
       7             : // http://www.boost.org/LICENSE_1_0.txt)
       8             : 
       9             : #include "mcrl2/gui/logwidget.h"
      10             : #include "ui_logwidget.h"
      11             : 
      12             : using namespace mcrl2::gui;
      13             : using namespace mcrl2::gui::qt;
      14             : 
      15           0 : void LogRelay::output(const log_level_t level,
      16             :                       const time_t timestamp, 
      17             :                       const std::string& msg, 
      18             :                       const bool /* print_time_information */)
      19             : {
      20           0 :   emit logMessage(QString::fromStdString(log_level_to_string(level)),
      21           0 :                   QDateTime::fromSecsSinceEpoch(timestamp), 
      22           0 :                   QString::fromStdString(msg));
      23           0 : }
      24             : 
      25           0 : LogWidget::LogWidget(QWidget *parent)
      26             :   : QWidget(parent),
      27           0 :     m_ui(new Ui::LogWidget)
      28             : {
      29           0 :   m_ui->setupUi(this);
      30           0 :   connect(&m_relay, SIGNAL(logMessage(QString, QDateTime, QString)), this, SLOT(writeMessage(QString, QDateTime, QString)));
      31           0 :   logger::register_output_policy(m_relay);
      32           0 : }
      33             : 
      34           0 : LogWidget::~LogWidget()
      35             : {
      36           0 :   delete m_ui;
      37           0 : }
      38             : 
      39           0 : void LogWidget::writeMessage(QString level, QDateTime timestamp, QString message)
      40             : {
      41           0 :   message = message.trimmed();
      42           0 :   if (!message.isEmpty())
      43             :   {
      44           0 :     QString formattedMessage = QString("[%1 %2] %3").arg(timestamp.toString("hh:mm:ss")).arg(level).arg(message).trimmed();
      45           0 :     switch (log_level_from_string(level.toStdString()))
      46             :     {
      47           0 :       case error:
      48           0 :         m_ui->editOutput->setTextColor(Qt::red);
      49           0 :         break;
      50           0 :       case warning:
      51           0 :         m_ui->editOutput->setTextColor(QColor("orange"));
      52           0 :         break;
      53           0 :       default:
      54           0 :         setTextEditTextColor(m_ui->editOutput, Qt::black, Qt::white);
      55           0 :         break;
      56             :     }
      57             : 
      58           0 :     m_ui->editOutput->append(formattedMessage);
      59           0 :     emit logMessage(level, timestamp, message, formattedMessage);
      60           0 :   }
      61           0 : }

Generated by: LCOV version 1.14