Skip to content

Commit

Permalink
talipot-core/config: Add log stream for info message type
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert committed Nov 21, 2024
1 parent b999c29 commit 9f11e27
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion library/talipot-core/include/talipot/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,16 @@ extern TLP_SCOPE std::ostream &error();
* @brief set the ostream used for the output of error messages
*/
extern TLP_SCOPE void setErrorOutput(std::ostream &os);

/**
*
* @brief return the ostream used for the output of info messages
*/
extern TLP_SCOPE std::ostream &info();
/**
*
* @brief set the ostream used for the output of info messages
*/
extern TLP_SCOPE void setInfoOutput(std::ostream &os);
/**
*
* @brief return the TALIPOT_VERSION value
Expand Down
8 changes: 8 additions & 0 deletions library/talipot-core/src/talipotconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ void tlp::setErrorOutput(std::ostream &os) {
errorStream = &os;
}

static std::ostream *infoStream = nullptr;
std::ostream &tlp::info() {
return infoStream ? *infoStream : std::cout;
}
void tlp::setInfoOutput(std::ostream &os) {
infoStream = &os;
}

std::string tlp::getTalipotVersion() {
return TALIPOT_VERSION;
}
2 changes: 1 addition & 1 deletion library/talipot-gui/include/talipot/TlpQtTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extern TLP_QT_SCOPE void initTalipotSoftware(PluginLoader *loader = nullptr);

/**
* @brief Redirect tlp::debug() to qDebug(), tlp::warning() to qWarning(),
* and tlp::error() to qCritical()
* tlp::error() to qCritical() and tlp::info() to qInfo()
*/
TLP_QT_SCOPE void redirectStreamOutputsToQt();

Expand Down
5 changes: 5 additions & 0 deletions library/talipot-gui/src/TlpQtTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class QDebugOStream : public std::ostream {
static unique_ptr<std::ostream> qDebugStream;
static unique_ptr<std::ostream> qWarningStream;
static unique_ptr<std::ostream> qErrorStream;
static unique_ptr<std::ostream> qInfoStream;

void redirectStreamOutputsToQt() {
if (qDebugStream.get() == nullptr) {
Expand All @@ -338,9 +339,13 @@ void redirectStreamOutputsToQt() {
if (qErrorStream.get() == nullptr) {
qErrorStream.reset(new QDebugOStream<QtCriticalMsg>());
}
if (qInfoStream.get() == nullptr) {
qInfoStream.reset(new QDebugOStream<QtInfoMsg>());
}
tlp::setDebugOutput(*qDebugStream);
tlp::setWarningOutput(*qWarningStream);
tlp::setErrorOutput(*qErrorStream);
tlp::setInfoOutput(*qInfoStream);
}

class NoQtUserInputFilter : public QObject {
Expand Down

0 comments on commit 9f11e27

Please sign in to comment.