Mantid
Loading...
Searching...
No Matches
QtSignalChannel.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10
11#include <Poco/Message.h>
12
13#include <utility>
14
16
24QtSignalChannel::QtSignalChannel(QString source) : QObject(), Poco::Channel(), m_source(std::move(source)) {}
25
27
32void QtSignalChannel::setSource(const QString &source) { m_source = source; }
33
41void QtSignalChannel::log(const Poco::Message &msg) {
42 if (m_source.isEmpty() || this->source() == msg.getSource().c_str()) {
43 emit messageReceived(Message(QString::fromStdString(msg.getText() + "\n"), msg.getPriority()));
44 }
45}
46
47/*
48 * @param priority An integer that must match the Poco::Message priority
49 * enumeration
50 */
53 Logger::setLevelForAll(priority);
54}
55} // namespace MantidQt::MantidWidgets
Provides a simple binding of a text message with a priority.
Definition: Message.h:28
QString m_source
Optional source (use std::string to avoid conversion in comparison)
void setGlobalLogLevel(int level)
Set the log level for all loggers.
void setSource(const QString &source)
If set, only Mantid log messages from this source are emitted.
const QString & source() const
Get the current source are emitted.
void messageReceived(const Message &msg)
void log(const Poco::Message &msg) override
Converts the Poco::Message to a Qt signal.
QtSignalChannel(QString source="")
Default constructor.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
static void setLevelForAll(const int level)
Sets the log level for all Loggers created so far, including the root logger.
Definition: Logger.cpp:297
Definition: Algorithm.h:30
STL namespace.