Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxReporterThread.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXREPORTERTHREAD_H
13 #define CXREPORTERTHREAD_H
14 
15 #include "cxResourceExport.h"
16 
17 //#define SSC_PRINT_CALLER_INFO
18 
19 #include <QMetaType>
20 #include <QObject>
21 #include <QMutex>
22 #include <QDateTime>
23 #include <QFile>
24 #include "boost/shared_ptr.hpp"
25 #include "boost/function.hpp"
26 #include "cxDefinitions.h"
27 #include "cxAudio.h"
28 #include <sstream>
29 #include "cxTypeConversions.h"
30 #include "cxLogger.h"
31 #include "cxLogMessage.h"
32 #include <QList>
33 #include <QThread>
34 #include "cxLogThread.h"
35 
36 class QString;
37 class QDomNode;
38 class QDomDocument;
39 class QFile;
40 class QTextStream;
41 
48 namespace cx
49 {
50 
55 class ReporterThread : public LogThread
56 {
57  Q_OBJECT
58 
59 public:
60  ReporterThread(QObject* parent = NULL);
61  virtual ~ReporterThread();
62 
63  void stopQtMessages();
64  void startQtMessages();
65 
66 public slots:
67  virtual void logMessage(Message msg);
68 
69 signals:
70  void emittedMessage(Message message);
71 
72 protected:
73  virtual void executeSetLoggingFolder(QString absoluteLoggingFolderPath);
74 
75 private slots:
76  void onMessageEmitted(Message msg);
77 private:
78  bool initializeLogFile(LogFile file);
79 
80  void sendToFile(Message message);
81  void sendToCout(Message message);
82 
83  typedef boost::shared_ptr<class SingleStreamerImpl> SingleStreamerImplPtr;
84  SingleStreamerImplPtr mCout;
85  SingleStreamerImplPtr mCerr;
86 
87  QString mLogPath;
88  QStringList mInitializedFiles;
89 
90 };
91 
92 } //namespace cx
93 
98 #endif // CXREPORTERTHREAD_H
virtual void logMessage(Message msg)
virtual void executeSetLoggingFolder(QString absoluteLoggingFolderPath)
void emittedMessage(Message message)
emitted for each new message, in addition to writing to file.
ReporterThread(QObject *parent=NULL)
Namespace for all CustusX production code.