General Purpose Geodetic Library
NsScrPrx4Logger.h
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of nuSolve. nuSolve is a part of CALC/SOLVE system
4  * and is designed to perform data analyis of a geodetic VLBI session.
5  * Copyright (C) 2017-2020 Sergei Bolotin.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NS_SCR_PRX_4_LOGGER_H
23 #define NS_SCR_PRX_4_LOGGER_H
24 
25 
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 
31 #include <QtCore/QtGlobal>
32 #include <QtCore/QObject>
33 #include <QtCore/QString>
34 
35 #if 0 < HAVE_SCRIPTS
36 # include <QtScript/QScriptEngine>
37 # include <QtScript/QScriptValue>
38 #endif
39 
40 #include <SgLogger.h>
41 
42 #include "nuSolve.h"
43 
44 
45 
46 class QString;
47 
48 extern const QString str_WRONG;
49 
50 extern const QString str_LogErr;
51 extern const QString str_LogWrn;
52 extern const QString str_LogInf;
53 extern const QString str_LogDbg;
54 
55 
56 
57 extern const QString str_LogIoBin;
58 extern const QString str_LogIoTxt;
59 extern const QString str_LogIoNcdf;
60 extern const QString str_LogIoDbh;
61 extern const QString str_LogIo;
62 
63 extern const QString str_LogMatrix;
64 extern const QString str_LogMatrix3D;
65 extern const QString str_LogInterp;
66 extern const QString str_LogMath;
67 
68 extern const QString str_LogObs;
69 extern const QString str_LogStation;
70 extern const QString str_LogSource;
71 extern const QString str_LogSession;
72 extern const QString str_LogData;
73 
74 extern const QString str_LogRefFrame;
75 extern const QString str_LogTime;
76 extern const QString str_LogIono;
77 extern const QString str_LogRefraction;
78 extern const QString str_LogDelay;
79 extern const QString str_LogRate;
80 extern const QString str_LogFlyBy;
81 extern const QString str_LogDisplacement;
82 extern const QString str_LogGeo;
83 
84 extern const QString str_LogEstimator;
85 extern const QString str_LogPwl;
86 extern const QString str_LogStoch;
87 extern const QString str_LogConfig;
88 extern const QString str_LogGui;
89 extern const QString str_LogReport;
90 extern const QString str_LogRun;
91 extern const QString str_LogPreproc;
92 extern const QString str_LogAll;
93 
94 
95 /***===================================================================================================*/
101 class NsScrPrx4Logger : public QObject
102 {
103  Q_OBJECT
104  Q_PROPERTY(QString fileName
105  WRITE setFileName READ getFileName)
106  Q_PROPERTY(QString dirName
107  WRITE setDirName READ getDirName)
108  Q_PROPERTY(bool have2store
109  WRITE setHave2store READ getHave2store)
110  Q_PROPERTY(bool isMute
111  WRITE setIsMute READ getIsMute)
112 
113  Q_ENUMS (LogLevel LogFacility)
114 
115 
116 public:
117  enum LogLevel
118  {
123  };
124 
126  {
159  };
160 
161 
162  //
163  // constructors/destructors:
164  //
168 
172  virtual ~NsScrPrx4Logger();
173 
174 
175  //
176  // Interfaces:
177  //
178 public slots:
179  inline const QString& getFileName() const {return logger_->getFileName();}
180  inline const QString& getDirName() const {return logger_->getDirName();}
181  inline bool getHave2store() const {return logger_->getIsStoreInFile();}
182  inline bool getIsMute() const {return logger_->getIsMute();}
183 
184  inline void setFileName(const QString& fname) {logger_->setFileName(fname);};
185  inline void setDirName(const QString& dname) {logger_->setDirName(dname);};
186  inline void setHave2store(bool have2) {logger_->setIsStoreInFile(have2);};
187  inline void setIsMute(bool is) {logger_->setIsMute(is);};
188 
189  //
190  inline void write(LogLevel lvl, quint32 f, const QString &s)
191  {if (logger_) logger_->write((SgLogger::LogLevel)lvl, f, s);};
192  inline void addLogFacility(LogLevel lvl, quint32 f)
194  inline void delLogFacility(LogLevel lvl, quint32 f)
196  inline bool isEligible(LogLevel lvl, quint32 f) const
197  {return logger_?logger_->isEligible((SgLogger::LogLevel)lvl, f):false;};
198 
199  inline void rmLogFile() {if (logger_) logger_->rmLogFile();};
200  inline void clearSpool() {if (logger_) logger_->clearSpool();};
201 
202 
203 
204 public:
205  //
206  // Functions:
207  //
208  inline QString className() const {return "NsScrPrx4Logger";};
209 
210 
211  //
212  // Friends:
213  //
214 
215 
216  //
217  // I/O:
218  //
219  //
220 
221 protected:
223 };
224 /*=====================================================================================================*/
225 
226 
227 
228 #if 0 < HAVE_SCRIPTS
229 
230 Q_DECLARE_METATYPE(NsScrPrx4Logger::LogLevel);
231 Q_DECLARE_METATYPE(NsScrPrx4Logger::LogFacility);
232 
233 #endif
234 
235 
236 /*=====================================================================================================*/
237 //
238 // aux functions:
239 //
240 #if 0 < HAVE_SCRIPTS
241 
242 #if QT_VERSION >= 0x040800
243 inline QScriptValue toScriptValue4LogLevel(QScriptEngine */*eng*/, const NsScrPrx4Logger::LogLevel &l)
244 {
245  return
250 };
251 #else
252 inline QScriptValue toScriptValue4LogLevel(QScriptEngine *eng, const NsScrPrx4Logger::LogLevel &)
253 {
254  return QScriptValue(eng, str_WRONG);
255 };
256 #endif
257 
258 
259 inline void fromScriptValue4LogLevel(const QScriptValue &obj, NsScrPrx4Logger::LogLevel &l)
260 {
261  l = (NsScrPrx4Logger::LogLevel) obj.toInt32();
262 };
263 
264 
265 
266 
267 
268 #if QT_VERSION >= 0x040800
269 inline QScriptValue toScriptValue4LogFacility(QScriptEngine */*eng*/,
271 {
272  return
304  )))))))))))))))))))))))))))));
305 };
306 #else
307 inline QScriptValue toScriptValue4LogFacility(QScriptEngine *eng, const NsScrPrx4Logger::LogFacility &)
308 {
309  return QScriptValue(eng, str_WRONG);
310 };
311 #endif
312 
313 
314 inline void fromScriptValue4LogFacility(const QScriptValue &obj, NsScrPrx4Logger::LogFacility &f)
315 {
316  f = (NsScrPrx4Logger::LogFacility) obj.toInt32();
317 };
318 
319 
320 #endif // SCRIPT_SUPPORT
321 
322 
323 /*=====================================================================================================*/
324 #endif // NS_SCR_PRX_4_LOGGER_H
const QString str_LogReport
const QString str_LogDelay
const QString str_LogRefFrame
const QString str_LogMatrix3D
const QString str_LogDbg
const QString str_LogEstimator
const QString str_LogStation
const QString str_LogIoDbh
const QString str_LogData
const QString str_LogTime
const QString str_LogStoch
const QString str_LogObs
const QString str_LogFlyBy
const QString str_LogInf
const QString str_LogIoBin
const QString str_LogConfig
const QString str_LogIono
const QString str_LogRate
const QString str_WRONG
const QString str_LogSession
const QString str_LogGui
const QString str_LogPreproc
const QString str_LogPwl
const QString str_LogErr
const QString str_LogInterp
const QString str_LogRun
const QString str_LogIoTxt
const QString str_LogDisplacement
const QString str_LogRefraction
const QString str_LogMath
const QString str_LogIo
const QString str_LogGeo
const QString str_LogWrn
const QString str_LogSource
const QString str_LogAll
const QString str_LogMatrix
const QString str_LogIoNcdf
SgLogger * logger
Definition: SgLogger.cpp:231
NsScrPrx4Logger(SgLogger *logger)
void write(LogLevel lvl, quint32 f, const QString &s)
void setHave2store(bool have2)
SgLogger * logger_
void setFileName(const QString &fname)
const QString & getFileName() const
bool getHave2store() const
bool getIsMute() const
void addLogFacility(LogLevel lvl, quint32 f)
QString className() const
bool isEligible(LogLevel lvl, quint32 f) const
virtual ~NsScrPrx4Logger()
const QString & getDirName() const
void setDirName(const QString &dname)
void delLogFacility(LogLevel lvl, quint32 f)
void setIsMute(bool is)
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
bool getIsStoreInFile() const
Definition: SgLogger.h:137
void setIsStoreInFile(bool isStoreInFile)
Definition: SgLogger.h:127
void delLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:150
void setFileName(const QString &fileName)
Definition: SgLogger.h:125
const QString & getDirName() const
Definition: SgLogger.h:134
void setDirName(const QString &dirName)
Definition: SgLogger.h:124
bool getIsMute() const
Definition: SgLogger.h:140
@ MATH
Definition: SgLogger.h:73
@ MATRIX
Definition: SgLogger.h:69
@ IO_NCDF
Definition: SgLogger.h:66
@ 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
@ 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
@ REFRACTION
Definition: SgLogger.h:82
@ CONFIG
Definition: SgLogger.h:93
@ FLY_BY
Definition: SgLogger.h:85
void addLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:149
virtual void clearSpool()
Definition: SgLogger.cpp:116
const QString & getFileName() const
Definition: SgLogger.h:135
bool isEligible(LogLevel lvl, quint32 f) const
Definition: SgLogger.h:151
void setIsMute(bool is)
Definition: SgLogger.h:130
void rmLogFile()
Definition: SgLogger.cpp:148