General Purpose Geodetic Library
SgLogger.h
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 #ifndef SG_LOGGER_H
24 #define SG_LOGGER_H
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 
32 #include <iostream>
33 
34 #include <QtCore/QString>
35 #include <QtCore/QList>
36 #include <QtCore/QMap>
37 
38 
39 
40 
41 class SgLogger;
42 extern SgLogger *logger;
43 
44 
45 
46 /***===================================================================================================*/
52 class SgLogger
53 {
54 public:
55  enum LogLevel
56  {
57  ERR, //<! Log level: error
58  WRN, //<! Log level: normal
59  INF, //<! Log level: info
60  DBG //<! Log level: debug
61  };
63  {
64  IO_BIN = 1<< 0, //<! Log facility:
65  IO_TXT = 1<< 1, //<! Log facility:
66  IO_NCDF = 1<< 2, //<! Log facility: NetCDF I/O manipulations
67  IO_DBH = 1<< 3, //<! Log facility: DBH I/O manipulations
69  MATRIX = 1<< 4, //<! Log facility: matrix/vector
70  MATRIX3D = 1<< 5, //<! Log facility: 3d matrix/3d vector
71  INTERP = 1<< 6, //<! Log facility: interpolations
72  MATH_RES_1 = 1<< 7, //<! Log facility:
74  OBS = 1<< 8, //<! Log facility:
75  STATION = 1<< 9, //<! Log facility: station
76  SOURCE = 1<<10, //<! Log facility: source
77  SESSION = 1<<11, //<! Log facility:
79  REF_FRAME = 1<<12, //<! Log facility:
80  TIME = 1<<13, //<! Log facility:
81  IONO = 1<<14, //<! Log facility: ionospheric corrections
82  REFRACTION = 1<<15, //<! Log facility: refraction delay
83  DELAY = 1<<16, //<! Log facility: grav. delay
84  RATE = 1<<17, //<! Log facility:
85  FLY_BY = 1<<18, //<! Log facility:
86  DISPLACEMENT= 1<<19, //<! Log facility:
87  GEO_RES_1 = 1<<20, //<! Log facility:
90  ESTIMATOR = 1<<21, //<! Log facility: estimator
91  PWL = 1<<22, //<! Log facility: piecewise linear parameters
92  STOCH = 1<<23, //<! Log facility: stochastic parameters
93  CONFIG = 1<<24, //<! Log facility: config
94  GUI = 1<<25, //<! Log facility: GUI
95  REPORT = 1<<26, //<! Log facility: report generator
96  RESOURCE = 1<<27, //<! Log facility: resource manager
97  RUN = 1<<28, //<! Log facility: project manager
98  PREPROC = 1<<29, //<! Log facility: preprocessing
99  RESERVED_1 = 1<<30, //<! Log facility: preprocessing
100  RESERVED_2 = 1<<31, //<! Log facility: preprocessing
101  ALL = IO | MATH | DATA | GEO | ESTIMATOR | PWL | STOCH | CONFIG | GUI | REPORT | RESOURCE |
103  };
104 
105  // Statics:
106 
107  //
108  // constructors/destructors:
109  //
112  SgLogger(int capacity=100, bool isStoreInFile=false, const QString& fileName="logger.log");
113 
114 
118  virtual ~SgLogger();
119 
120 
121  //
122  // Interfaces:
123  //
124  inline void setDirName(const QString &dirName) {dirName_ = dirName;};
125  inline void setFileName(const QString &fileName) {fileName_ = fileName;};
126  inline void setCapacity(int capacity) {capacity_ = capacity;};
127  inline void setIsStoreInFile(bool isStoreInFile) {isStoreInFile_ = isStoreInFile;};
128  inline void setUseFullDateFormat(bool useFullDateFormat) {useFullDateFormat_ = useFullDateFormat;};
129  inline void setIsNeedTimeMark(bool isNeedTimeMark) {isNeedTimeMark_ = isNeedTimeMark;};
130  inline void setIsMute(bool is) {isMute_ = is;};
131  inline void setLogFacility(LogLevel lvl, quint32 f) {logFacilities_[lvl] = f;};
132  inline void setFacilitiesSerialNumber(double sn) {facilitiesSerialNumber_ = sn;};
133 
134  inline const QString& getDirName() const {return dirName_;};
135  inline const QString& getFileName() const {return fileName_;};
136  inline int getCapacity() const {return capacity_;};
137  inline bool getIsStoreInFile() const {return isStoreInFile_;};
138  inline bool getUseFullDateFormat() const {return useFullDateFormat_;};
139  inline bool getIsNeedTimeMark() const {return isNeedTimeMark_;};
140  inline bool getIsMute() const {return isMute_;};
141  inline quint32 getLogFacility(LogLevel lvl) const {return logFacilities_[lvl];};
142  inline double getFacilitiesSerialNumber() const {return facilitiesSerialNumber_;};
143  inline const QList<QString*>& getSpool() const {return spool_;};
144 
145  //
146  // Functions:
147  //
148  inline QString className() const {return "SgLogger";};
149  inline void addLogFacility(LogLevel lvl, quint32 f) {logFacilities_[lvl] |= f;};
150  inline void delLogFacility(LogLevel lvl, quint32 f) {logFacilities_[lvl] &= ~f;};
151  inline bool isEligible(LogLevel lvl, quint32 f) const {return logFacilities_[lvl]&f;};
152  virtual void startUp();
153  virtual void clearSpool();
154  virtual void write(LogLevel, quint32, const QString &, bool=false);
155  //
156  void attachSupplementLog(const QString& name, SgLogger *auxLogger);
157  void detachSupplementLog(const QString& name);
158  SgLogger* lookupSupplementLog(const QString& name);
159  void rmLogFile();
160 
161 
162 
163  //
164  // Friends:
165  //
166 
167 
168  //
169  // I/O:
170  //
171  // ...
172 
173 
174 protected:
178  bool isMute_;
179  QString dirName_;
180  QString fileName_;
182  quint32 logFacilities_[4];
185  QMap<QString, SgLogger*> logSupplements_;
186 
187  virtual void makeOutput(LogLevel level, const QString &s, bool isAsync);
188 };
189 /*=====================================================================================================*/
190 
191 
192 
193 
194 
195 
196 
197 
198 /*=====================================================================================================*/
199 /* */
200 /* geo_MJD inline members: */
201 /* */
202 /*=====================================================================================================*/
203 //
204 //
205 // CONSTRUCTORS:
206 //
207 // An empty constructor:
208 
209 
210 
211 
212 
213 
214 // A destructor:
215 
216 
217 
218 //
219 // INTERFACES:
220 //
221 
222 
223 
224 
225 //
226 // FUNCTIONS:
227 //
228 //
229 //
230 
231 
232 
233 
234 //
235 // FRIENDS:
236 //
237 //
238 //
239 
240 
241 
242 /*=====================================================================================================*/
243 
244 
245 
246 
247 
248 /*=====================================================================================================*/
249 //
250 // aux functions:
251 //
252 
253 
254 /*=====================================================================================================*/
255 #endif //SG_LOGGER_H
256 
SgLogger * logger
Definition: SgLogger.cpp:231
bool isMute_
Definition: SgLogger.h:178
void setFacilitiesSerialNumber(double sn)
Definition: SgLogger.h:132
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
QString fileName_
Definition: SgLogger.h:180
SgLogger(int capacity=100, bool isStoreInFile=false, const QString &fileName="logger.log")
Definition: SgLogger.cpp:39
const QList< QString * > & getSpool() const
Definition: SgLogger.h:143
bool getIsStoreInFile() const
Definition: SgLogger.h:137
void attachSupplementLog(const QString &name, SgLogger *auxLogger)
Definition: SgLogger.cpp:172
void setIsStoreInFile(bool isStoreInFile)
Definition: SgLogger.h:127
SgLogger * lookupSupplementLog(const QString &name)
Definition: SgLogger.cpp:199
void delLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:150
QString dirName_
Definition: SgLogger.h:179
void setLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:131
void setFileName(const QString &fileName)
Definition: SgLogger.h:125
void setIsNeedTimeMark(bool isNeedTimeMark)
Definition: SgLogger.h:129
double getFacilitiesSerialNumber() const
Definition: SgLogger.h:142
quint32 getLogFacility(LogLevel lvl) const
Definition: SgLogger.h:141
virtual void makeOutput(LogLevel level, const QString &s, bool isAsync)
Definition: SgLogger.cpp:163
const QString & getDirName() const
Definition: SgLogger.h:134
QMap< QString, SgLogger * > logSupplements_
Definition: SgLogger.h:185
void setDirName(const QString &dirName)
Definition: SgLogger.h:124
bool getIsMute() const
Definition: SgLogger.h:140
LogFacility
Definition: SgLogger.h:63
@ MATH
Definition: SgLogger.h:73
@ MATRIX
Definition: SgLogger.h:69
@ IO_NCDF
Definition: SgLogger.h:66
@ RESERVED_2
Definition: SgLogger.h:100
@ STOCH
Definition: SgLogger.h:92
@ ESTIMATOR
Definition: SgLogger.h:90
@ IO_TXT
Definition: SgLogger.h:65
@ DELAY
Definition: SgLogger.h:83
@ IO_BIN
Definition: SgLogger.h:64
@ TIME
Definition: SgLogger.h:80
@ GEO_RES_1
Definition: SgLogger.h:87
@ SOURCE
Definition: SgLogger.h:76
@ IO_DBH
Definition: SgLogger.h:67
@ MATRIX3D
Definition: SgLogger.h:70
@ INTERP
Definition: SgLogger.h:71
@ RATE
Definition: SgLogger.h:84
@ IONO
Definition: SgLogger.h:81
@ DISPLACEMENT
Definition: SgLogger.h:86
@ DATA
Definition: SgLogger.h:78
@ REPORT
Definition: SgLogger.h:95
@ STATION
Definition: SgLogger.h:75
@ PREPROC
Definition: SgLogger.h:98
@ SESSION
Definition: SgLogger.h:77
@ REF_FRAME
Definition: SgLogger.h:79
@ RESOURCE
Definition: SgLogger.h:96
@ REFRACTION
Definition: SgLogger.h:82
@ RESERVED_1
Definition: SgLogger.h:99
@ CONFIG
Definition: SgLogger.h:93
@ MATH_RES_1
Definition: SgLogger.h:72
@ FLY_BY
Definition: SgLogger.h:85
void addLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:149
QString className() const
Definition: SgLogger.h:148
virtual void clearSpool()
Definition: SgLogger.cpp:116
void setCapacity(int capacity)
Definition: SgLogger.h:126
virtual ~SgLogger()
Definition: SgLogger.cpp:61
bool useFullDateFormat_
Definition: SgLogger.h:177
bool getIsNeedTimeMark() const
Definition: SgLogger.h:139
bool isNeedTimeMark_
Definition: SgLogger.h:176
QList< QString * > spool_
Definition: SgLogger.h:181
virtual void startUp()
Definition: SgLogger.cpp:74
double facilitiesSerialNumber_
Definition: SgLogger.h:184
const QString & getFileName() const
Definition: SgLogger.h:135
int getCapacity() const
Definition: SgLogger.h:136
bool isStoreInFile_
Definition: SgLogger.h:175
quint32 logFacilities_[4]
Definition: SgLogger.h:182
bool getUseFullDateFormat() const
Definition: SgLogger.h:138
int capacity_
Definition: SgLogger.h:183
bool isEligible(LogLevel lvl, quint32 f) const
Definition: SgLogger.h:151
void setIsMute(bool is)
Definition: SgLogger.h:130
void detachSupplementLog(const QString &name)
Definition: SgLogger.cpp:187
void setUseFullDateFormat(bool useFullDateFormat)
Definition: SgLogger.h:128
void rmLogFile()
Definition: SgLogger.cpp:148