Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
log.cpp
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 system messages
22 //=============================================================================
23 
24 #include "log.h"
25 
27 
28 
29 int getVerbosity() { return messageVerbosity; }
30 
31 //-----------------------------------------------------------------------------
32 // Global function generating the log message string
33 //-----------------------------------------------------------------------------
42 
43 QString createLogMessage (int line, QString path, QString function, int level)
44 {
45  QStringList parts = path.split("/");
46  QString filename = parts.at(parts.size()-1);
47  QString str;
48  QTextStream msg(&str);
49  msg << "(" << function << " in " << filename << ":" << line << "):";
50  if (level>4) msg << "\nFull path: " << path << "\n";
51  return str;
52 }
53 
54 
55 //-----------------------------------------------------------------------------
56 // Log - Base class constructor
57 //-----------------------------------------------------------------------------
63 
65  : messageVerbosity(2)
66  , mModule("Unknown Module")
67 {
68 }
69 
70 
71 //-----------------------------------------------------------------------------
72 // Set module name
73 //-----------------------------------------------------------------------------
81 
82 void Log::setModuleName (const QString &name) { mModule = name; }
83 
84 
85 //-----------------------------------------------------------------------------
86 // Get module name
87 //-----------------------------------------------------------------------------
92 
93 QString Log::getModuleName() const
94 {
95  return mModule;
96 }
97 
98 
99 //-----------------------------------------------------------------------------
100 // Set verbosity
101 //-----------------------------------------------------------------------------
106 
107 void Log::setVerbosity(int verbosity) { messageVerbosity = verbosity; }
108 
109 
110 //-----------------------------------------------------------------------------
111 // Get verbosity
112 //-----------------------------------------------------------------------------
117 
119 
120 
121 //-----------------------------------------------------------------------------
122 // Class-specific function generating the log message string
123 //-----------------------------------------------------------------------------
132 
133 QString Log::createLogMessage(int line, QString path, QString function, int level)
134 {
135  QStringList parts = path.split("/");
136  QString filename = parts.at(parts.size()-1);
137  QString str;
138  QTextStream msg(&str);
139  msg << mModule << " (" << function << " in " << filename << ":" << line << "):";
140  if (level>4) msg << "\nFull path: " << path << "\n";
141  return str;
142 }
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
QString createLogMessage(int line, QString path, QString function, int level)
Global function generating the log message string.
Definition: log.cpp:43
Log()
Constructor of the Log base class.
Definition: log.cpp:64
int messageVerbosity
Verbosity of error messages.
Definition: log.h:101
void setVerbosity(int verbosity)
Set the verbosity level of the class-specific messages.
Definition: log.cpp:107
int messageVerbosity
Global verbosity level.
Definition: log.cpp:26
int getVerbosity()
Definition: log.cpp:29
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