Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxLog.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 CXLOG_H
13 #define CXLOG_H
14 
15 #include "cxResourceExport.h"
16 
17 #include <QMetaType>
18 #include <QObject>
19 #include <QMutex>
20 #include <QDateTime>
21 #include <QFile>
22 #include "boost/shared_ptr.hpp"
23 #include "cxDefinitions.h"
24 #include "cxAudio.h"
25 #include <sstream>
26 #include "cxTypeConversions.h"
27 #include "cxLogger.h"
28 #include "cxLogMessage.h"
29 
30 class QString;
31 class QDomNode;
32 class QDomDocument;
33 class QFile;
34 class QTextStream;
35 
42 namespace cx
43 {
44 typedef boost::shared_ptr<class MessageObserver> MessageObserverPtr;
45 typedef boost::shared_ptr<class MessageListener> MessageListenerPtr;
46 typedef boost::shared_ptr<class LogThread> LogThreadPtr;
47 typedef boost::shared_ptr<class ReporterThread> ReporterThreadPtr;
48 typedef boost::shared_ptr<class Log> LogPtr;
49 
56 class cxResource_EXPORT Log : public QObject
57 {
58  Q_OBJECT
59 
60 public:
61  virtual ~Log();
62 
63  QString getLoggingFolder() const;
64  void setLoggingFolder(QString absoluteLoggingFolderPath);
65 
66  void installObserver(MessageObserverPtr observer, bool resend);
67  void uninstallObserver(MessageObserverPtr observer);
68  void stopQtMessages();
69  void startQtMessages();
70 
71 signals:
72  void loggingFolderChanged();
73 
74 protected:
75  virtual LogThreadPtr createWorker() = 0;
76 
77 protected slots:
78  virtual void onEmittedMessage(Message message) {}
79 
80 protected:
81  Log();
82 
83  void initializeObject();
84  void startThread();
85  void stopThread();
86 
87  QString getDefaultLogPath() const;
88  QString mLogPath;
89  boost::shared_ptr<class QThread> mThread;
90  LogThreadPtr mWorker;
91 private:
92  Log(const Log&);
93  Log& operator=(const Log&);
94 };
95 
96 
97 } //namespace cx
98 
103 #endif // CXLOG_H
boost::shared_ptr< class ReporterThread > ReporterThreadPtr
Definition: cxLog.h:47
virtual void onEmittedMessage(Message message)
Definition: cxLog.h:78
QString mLogPath
Definition: cxLog.h:88
boost::shared_ptr< class QThread > mThread
Definition: cxLog.h:89
boost::shared_ptr< class Log > LogPtr
Definition: cxLog.h:48
boost::shared_ptr< class MessageObserver > MessageObserverPtr
Definition: cxLog.h:44
Definition: cxLog.h:56
LogThreadPtr mWorker
Definition: cxLog.h:90
boost::shared_ptr< class LogThread > LogThreadPtr
Definition: cxLog.h:46
boost::shared_ptr< class MessageListener > MessageListenerPtr
Definition: cxLog.h:45
Namespace for all CustusX production code.