Just Intonation  Version 1.3.0 (18)
Explore scale-independent dynamically adapting tuning in just intonation
log.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Log - Base class managing log messages
22 //=============================================================================
23 
24 #ifndef LOG_H
25 #define LOG_H
26 
27 #include <qdebug.h>
28 
29 //--------------- Workaround for errors on mobiles for debugging --------------
30 
31 extern void mobileError(QString msg);
32 
33 //------------- Helper macro calling the function message(...) ----------------
34 
35 #ifdef __GNUC__
36 #define LOGMSG(level) createLogMessage(__LINE__ ,__FILE__,__PRETTY_FUNCTION__,level).toStdString().c_str()
37 #else
38 #define LOGMSG(level) createLogMessage(__LINE__ ,__FILE__,__FUNCTION__,level).toStdString().c_str()
39 #endif
40 //----------------------- Macros used by the user -----------------------------
41 
42 #define LOGSTATUS if (getVerbosity() >= 4) qDebug() << LOGMSG(4)
43 #define LOGMESSAGE if (getVerbosity() >= 3) qDebug() << LOGMSG(3)
44 #define LOGWARNING if (getVerbosity() >= 2) qWarning() << "WARNING" << LOGMSG(2)
45 #define LOGERROR if (getVerbosity() >= 1) qCritical() << "ERROR" << LOGMSG(1)
46 
47 //--------------------------- Global defintions -------------------------------
48 
49 extern int messageVerbosity;
50 
51 //------------ Global function generating the log message string --------------
52 
53 QString createLogMessage (int line, QString path, QString function, int level);
54 
55 //------------------------ Non-global definitions -----------------------------
56 
82 
83 class Log
84 {
85 protected:
86  Log();
87 
88 public:
89  void setVerbosity (int verbosity);
90  int getVerbosity();
91 
92 protected:
94  QString createLogMessage (int line, QString path, QString function, int level);
96  void setModuleName (const QString &name);
98  QString getModuleName() const;
99 
100 private:
102  QString mModule;
103 };
104 
105 #endif // LOG_H
QString getModuleName() const
Get module name.
Definition: log.cpp:93
void setModuleName(const QString &name)
Specify the name of the class-specific module.
Definition: log.cpp:82
int getVerbosity()
Get the actual verbosity level.
Definition: log.cpp:118
Log()
Constructor of the Log base class.
Definition: log.cpp:64
int messageVerbosity
Verbosity of error messages.
Definition: log.h:101
QString createLogMessage(int line, QString path, QString function, int level)
Global function generating the log message string.
Definition: log.cpp:43
void mobileError(QString msg)
void setVerbosity(int verbosity)
Set the verbosity level of the class-specific messages.
Definition: log.cpp:107
QString createLogMessage(int line, QString path, QString function, int level)
Class-specific function generating the log message string.
Definition: log.cpp:133
QString mModule
Name of the module.
Definition: log.h:102
Base class for managing log messages.
Definition: log.h:83
int messageVerbosity
Verbosity of global error messages.
Definition: log.cpp:26