General Purpose Geodetic Library
SgGuiLogger.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <SgGuiLogger.h>
24 #if QT_VERSION >= 0x050000
25 # include <QtWidgets/QApplication>
26 #else
27 # include <QtGui/QApplication>
28 #endif
29 
30 
31 /*=======================================================================================================
32 *
33 * METHODS:
34 *
35 *======================================================================================================*/
36 SgGuiLogger::SgGuiLogger(QWidget* parent, int capacity, bool isStoreInFile, const QString& fileName)
37  : QPlainTextEdit(parent), SgLogger(capacity, isStoreInFile, fileName)
38 
39 {
40  setReadOnly(true);
41  setMaximumBlockCount (3*capacity_);
42 
43  errFormat = currentCharFormat();
44  errFormat.setFontWeight(QFont::Bold);
45  errFormat.setForeground(QColor(222, 0, 0));
46 
47  wrnFormat = currentCharFormat();
48  wrnFormat.setFontWeight(QFont::Bold);
49  // wrnFormat.setForeground(QColor(30, 50, 180));
50  // wrnFormat.setForeground(QColor(204, 120, 0));
51  wrnFormat.setForeground(QColor(30, 98, 255));
52 
53  infFormat = currentCharFormat();
54  infFormat.setFontWeight(QFont::Bold);
55  // infFormat.setForeground(QColor(0, 125, 90));
56  // infFormat.setForeground(QColor(0, 125, 124));
57  infFormat.setForeground(QColor(0, 127, 140));
58 
59  dbgFormat = currentCharFormat();
60  setCenterOnScroll(true);
61  //setTextInteractionFlags(Qt::NoTextInteraction);
62 };
63 
64 
65 
66 void SgGuiLogger::makeOutput(LogLevel level, const QString &s, bool isAsync)
67 {
68  QTextCharFormat *format=NULL;
69  switch (level)
70  {
71  case ERR:
72  format = &errFormat;
73  break;
74  case WRN:
75  format = &wrnFormat;
76  break;
77  case INF:
78  format = &infFormat;
79  break;
80  case DBG:
81  default:
82  format = &dbgFormat;
83  break;
84  };
85 
86  setCurrentCharFormat(*format);
87  appendPlainText(s);
88 // appendHtml(s);
89  if (isAsync)
90  qApp->processEvents();
91 };
92 
93 
94 
96 {
98  logger->write(DBG, IO_TXT, ClassName() + ": the spool has been cleared");
99 };
100 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
SgGuiLogger(QWidget *, int=100, bool=true, const QString &="logger.log")
Definition: SgGuiLogger.cpp:36
virtual QString ClassName() const
Definition: SgGuiLogger.h:58
QTextCharFormat errFormat
Definition: SgGuiLogger.h:51
QTextCharFormat wrnFormat
Definition: SgGuiLogger.h:54
QTextCharFormat dbgFormat
Definition: SgGuiLogger.h:56
virtual void makeOutput(LogLevel, const QString &, bool)
Definition: SgGuiLogger.cpp:66
QTextCharFormat infFormat
Definition: SgGuiLogger.h:55
virtual void clearSpool()
Definition: SgGuiLogger.cpp:95
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_TXT
Definition: SgLogger.h:65
virtual void clearSpool()
Definition: SgLogger.cpp:116
int capacity_
Definition: SgLogger.h:183