14 changed files with 85 additions and 39 deletions
@ -0,0 +1,48 @@
|
||||
#include "logger.hpp" |
||||
#include "mainwindow.hpp" |
||||
#include "notifications.hpp" |
||||
#include <QDebug> |
||||
#include <iostream> |
||||
#include <stdlib.h> |
||||
#include <ui_mainwindow.h> |
||||
|
||||
void logger::info(QString info) { |
||||
qInfo() << info; |
||||
if (MainWindow::inst() && MainWindow::inst()->valid()) { |
||||
MainWindow::inst()->ui->logBox->addItem(info); |
||||
notifications::notifyNolog(QObject::tr("KShare Message"), info, QSystemTrayIcon::Information); |
||||
} |
||||
} |
||||
|
||||
void logger::warn(QString info) { |
||||
qWarning() << info; |
||||
if (MainWindow::inst() && MainWindow::inst()->valid()) { |
||||
MainWindow::inst()->ui->logBox->addItem(info); |
||||
notifications::notifyNolog(QObject::tr("KShare Warning"), info, QSystemTrayIcon::Warning); |
||||
} |
||||
} |
||||
|
||||
void logger::error(QString info) { |
||||
std::cerr << "ERROR: " << info.toStdString(); |
||||
if (MainWindow::inst() && MainWindow::inst()->valid()) { |
||||
MainWindow::inst()->ui->logBox->addItem(info); |
||||
notifications::notifyNolog(QObject::tr("KShare Error"), info, QSystemTrayIcon::Critical); |
||||
} |
||||
} |
||||
|
||||
void logger::fatal(QString info) { |
||||
std::cerr << "FATAL: " << info.toStdString(); |
||||
if (MainWindow::inst() && MainWindow::inst()->valid()) { |
||||
MainWindow::inst()->ui->logBox->addItem(info); |
||||
notifications::notifyNolog(QObject::tr("KShare Fatal Error"), info, QSystemTrayIcon::Critical); |
||||
} |
||||
} |
||||
|
||||
void logger::abort(QString info) { |
||||
std::cerr << "ABORT:" << info.toStdString(); |
||||
if (MainWindow::inst() && MainWindow::inst()->valid()) { |
||||
MainWindow::inst()->ui->logBox->addItem(info); |
||||
notifications::notifyNolog(QObject::tr("KShare Even More Fatal Error"), info, QSystemTrayIcon::Critical); |
||||
} |
||||
::abort(); |
||||
} |
@ -0,0 +1,14 @@
|
||||
#ifndef LOGGER_HPP |
||||
#define LOGGER_HPP |
||||
|
||||
#include <QString> |
||||
|
||||
namespace logger { |
||||
void info(QString info); // Something went okay, notify user about it
|
||||
void warn(QString info); // Something that does not interrupt execution, but could be improved
|
||||
void error(QString info); // Oh no - it errored, but is recoverable, and still important enough to notify
|
||||
void fatal(QString info); // Unrecoverable error, procedure aborts and notifies the user
|
||||
void abort(QString info); // tell the user that it gonna ded
|
||||
} |
||||
|
||||
#endif /* LOGGER_HPP */ |
Loading…
Reference in new issue