QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsserverlogger.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsserverlogger.h
3 -----------------
4 begin : May 5, 2014
5 copyright : (C) 2014 by Marco Hugentobler
6 email : marco dot hugentobler at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSSERVERLOGGER_H
19#define QGSSERVERLOGGER_H
20
21
22#include "qgsmessagelog.h"
23
24#include <QFile>
25#include <QObject>
26#include <QString>
27#include <QTextStream>
28#include "qgis_server.h"
29
35class SERVER_EXPORT QgsServerLogger : public QgsMessageLogConsole
36{
37 Q_OBJECT
38 public:
39
43 static QgsServerLogger *instance();
44
50 Qgis::MessageLevel logLevel() const { return mLogLevel; }
51
57 void setLogLevel( Qgis::MessageLevel level );
58
62 void setLogFile( const QString &filename = QString() );
63
68 void setLogStderr();
69
70 public slots:
71
79 void logMessage( const QString &message, const QString &tag, Qgis::MessageLevel level ) override;
80
81 protected:
83
84 private:
85 static QgsServerLogger *sInstance;
86
87 QFile mLogFile;
88 bool mLogStderr = false;
89 QTextStream mTextStream;
90 Qgis::MessageLevel mLogLevel = Qgis::MessageLevel::NoLevel;
91};
92
93#endif // QGSSERVERLOGGER_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:115
Default implementation of message logging interface.
virtual void logMessage(const QString &message, const QString &tag, Qgis::MessageLevel level)
Logs a message to stderr.
Writes message log into server logfile.
Qgis::MessageLevel logLevel() const
Gets the current log level.