QGIS API Documentation  3.19.0-Master (26212d215f)
qgsmessagelog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmessagelog.h - interface for logging messages
3  ----------------------
4  begin : October 2011
5  copyright : (C) 2011 by Juergen E. Fischer
6  email : jef at norbit dot de
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMESSAGELOG_H
17 #define QGSMESSAGELOG_H
18 
19 #include <QString>
20 #include <QObject>
21 
22 #include "qgis_core.h"
23 #include "qgis.h"
24 
39 class CORE_EXPORT QgsMessageLog : public QObject
40 {
41  Q_OBJECT
42 
43  public:
44 
48  QgsMessageLog() = default;
49 
57  static void logMessage( const QString &message, const QString &tag = QString(), Qgis::MessageLevel level = Qgis::Warning, bool notifyUser = true );
58 
59  signals:
60 
67  void messageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level );
68 
69  //TODO QGIS 4.0 - remove received argument
70 
79  void messageReceived( bool received );
80 
81  private:
82 
83  void emitMessage( const QString &message, const QString &tag, Qgis::MessageLevel level, bool notifyUser = true );
84 
85  int mAdviseBlockCount = 0;
86 
88 
89 };
90 
104 class CORE_EXPORT QgsMessageLogNotifyBlocker
105 {
106  public:
107 
114 
117 
120 
122 
123  private:
124 
125 #ifdef SIP_RUN
127 #endif
128 };
129 
137 class CORE_EXPORT QgsMessageLogConsole : public QObject
138 {
139  Q_OBJECT
140 
141  public:
142 
147 
148  protected:
149 
158  QString formatLogMessage( const QString &message, const QString &tag, Qgis::MessageLevel level = Qgis::Info ) const;
159 
160  public slots:
161 
169  virtual void logMessage( const QString &message, const QString &tag, Qgis::MessageLevel level );
170 };
171 
172 #endif
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:89
@ Warning
Definition: qgis.h:91
@ Info
Definition: qgis.h:90
Default implementation of message logging interface.
Temporarily blocks the application QgsMessageLog (see QgsApplication::messageLog()) from emitting the...
QgsMessageLogNotifyBlocker(const QgsMessageLogNotifyBlocker &other)=delete
QgsMessageLogNotifyBlocker cannot be copied.
QgsMessageLogNotifyBlocker & operator=(const QgsMessageLogNotifyBlocker &other)=delete
QgsMessageLogNotifyBlocker cannot be copied.
Interface for logging messages from QGIS in GUI independent way.
Definition: qgsmessagelog.h:40
void messageReceived(const QString &message, const QString &tag, Qgis::MessageLevel level)
Emitted whenever the log receives a message.
void messageReceived(bool received)
Emitted whenever the log receives a message which is not a Qgis::Info level message and which has the...
QgsMessageLog()=default
Constructor for QgsMessageLog.