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  Q_PROPERTY(int returnCode
113  WRITE setReturnCode READ getReturnCode)
114 
115  Q_ENUMS (LogLevel LogFacility)
116 
117 
118 public:
119  enum LogLevel
120  {
125  };
126 
128  {
161  };
162 
163 
164  //
165  // constructors/destructors:
166  //
170 
174  virtual ~NsScrPrx4Logger();
175 
176 
177  //
178  // Interfaces:
179  //
180 public slots:
181  inline const QString& getFileName() const {return logger_->getFileName();}
182  inline const QString& getDirName() const {return logger_->getDirName();}
183  inline bool getHave2store() const {return logger_->getIsStoreInFile();}
184  inline bool getIsMute() const {return logger_->getIsMute();}
185  inline int getReturnCode() const {return returnCode_;}
186 
187  inline quint32 getLogFacility(LogLevel lvl) const
188  {return (logger_!=NULL)?logger_->getLogFacility((SgLogger::LogLevel)lvl):0;};
189 
190  inline void setFileName(const QString& fname) {logger_->setFileName(fname);};
191  inline void setDirName(const QString& dname) {logger_->setDirName(dname);};
192  inline void setHave2store(bool have2) {logger_->setIsStoreInFile(have2);};
193  inline void setIsMute(bool is) {logger_->setIsMute(is);};
194  inline void setReturnCode(int rc) {returnCode_ = rc;};
195 
196  //
197  inline void write(LogLevel lvl, quint32 f, const QString &s)
198  {if (logger_) logger_->write((SgLogger::LogLevel)lvl, f, s);};
199  inline void addLogFacility(LogLevel lvl, quint32 f)
201  inline void delLogFacility(LogLevel lvl, quint32 f)
203  inline void selLogFacility(LogLevel lvl, quint32 f)
205  inline bool isEligible(LogLevel lvl, quint32 f) const
206  {return logger_?logger_->isEligible((SgLogger::LogLevel)lvl, f):false;};
207 
208  inline void rmLogFile() {if (logger_) logger_->rmLogFile();};
209  inline void clearSpool() {if (logger_) logger_->clearSpool();};
210 
211 
212 
213 public:
214  //
215  // Functions:
216  //
217  inline QString className() const {return "NsScrPrx4Logger";};
218 
219 
220  //
221  // Friends:
222  //
223 
224 
225  //
226  // I/O:
227  //
228  //
229 
230 protected:
233 };
234 /*=====================================================================================================*/
235 
236 
237 
238 #if 0 < HAVE_SCRIPTS
239 
240 Q_DECLARE_METATYPE(NsScrPrx4Logger::LogLevel);
241 Q_DECLARE_METATYPE(NsScrPrx4Logger::LogFacility);
242 
243 #endif
244 
245 
246 /*=====================================================================================================*/
247 //
248 // aux functions:
249 //
250 #if 0 < HAVE_SCRIPTS
251 
252 #if QT_VERSION >= 0x040800
253 inline QScriptValue toScriptValue4LogLevel(QScriptEngine */*eng*/, const NsScrPrx4Logger::LogLevel &l)
254 {
255  return
260 };
261 #else
262 inline QScriptValue toScriptValue4LogLevel(QScriptEngine *eng, const NsScrPrx4Logger::LogLevel &)
263 {
264  return QScriptValue(eng, str_WRONG);
265 };
266 #endif
267 
268 
269 inline void fromScriptValue4LogLevel(const QScriptValue &obj, NsScrPrx4Logger::LogLevel &l)
270 {
271  l = (NsScrPrx4Logger::LogLevel) obj.toInt32();
272 };
273 
274 
275 
276 
277 
278 #if QT_VERSION >= 0x040800
279 inline QScriptValue toScriptValue4LogFacility(QScriptEngine */*eng*/,
281 {
282  return
314  )))))))))))))))))))))))))))));
315 };
316 #else
317 inline QScriptValue toScriptValue4LogFacility(QScriptEngine *eng, const NsScrPrx4Logger::LogFacility &)
318 {
319  return QScriptValue(eng, str_WRONG);
320 };
321 #endif
322 
323 
324 inline void fromScriptValue4LogFacility(const QScriptValue &obj, NsScrPrx4Logger::LogFacility &f)
325 {
326  f = (NsScrPrx4Logger::LogFacility) obj.toInt32();
327 };
328 
329 
330 #endif // SCRIPT_SUPPORT
331 
332 
333 /*=====================================================================================================*/
334 #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 selLogFacility(LogLevel lvl, quint32 f)
void addLogFacility(LogLevel lvl, quint32 f)
QString className() const
bool isEligible(LogLevel lvl, quint32 f) const
int getReturnCode() const
virtual ~NsScrPrx4Logger()
quint32 getLogFacility(LogLevel lvl) const
const QString & getDirName() const
void setDirName(const QString &dname)
void delLogFacility(LogLevel lvl, quint32 f)
void setIsMute(bool is)
void setReturnCode(int rc)
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 setLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:131
void setFileName(const QString &fileName)
Definition: SgLogger.h:125
quint32 getLogFacility(LogLevel lvl) const
Definition: SgLogger.h:141
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