kradio4  r778
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
thread-logging.h
Go to the documentation of this file.
1 /***************************************************************************
2  thread-logging.h - description
3  -------------------
4  begin : Sun Feb 12 2012
5  copyright : (C) 2012 by Martin Witte
6  email : emw-kradio@nocabal.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef __THREAD_LOGGING_H__
19 #define __THREAD_LOGGING_H__
20 
21 
22 #include <QtCore/QMutex>
23 #include <QtCore/QString>
24 #include <errorlog_interfaces.h>
25 
26 // logging in thread
27 class KDE_EXPORT ThreadLogging
28 {
29 public:
30 
31  enum LoggingClass { LogInfo, LogWarning, LogDebug, LogError };
32 
33  ThreadLogging();
34 
35  bool hasLog (LoggingClass cls) const;
36  QStringList getLogs(LoggingClass cls, bool resetLog = true);
37 
38  QList<LoggingClass> getLogClasses() const;
39 
40  void log (LoggingClass cls, QString logString);
41 
42 private:
43  mutable QMutex m_accessLock;
44  QMap<LoggingClass, QStringList> logs;
45 };
46 
47 
48 
49 // receiving logs outside the thread
50 class KDE_EXPORT ThreadLoggingClient
51 {
52 public:
54  virtual ~ThreadLoggingClient();
55 
56  // returns false if there logs of class LogError are available
57  bool checkLogs(ThreadLogging *threadLogger, QString logPrefix, bool resetLogs = true);
58 
59 
60 protected:
61  virtual IErrorLogClient *getErrorLogClient() = 0;
62 
63 
64 protected:
65  // returns true if some messages were logged
66  bool checkLogs(ThreadLogging *threadLogger, ThreadLogging::LoggingClass cls, QString logPrefix, IErrorLogClient::logFunction_t logFunc, bool resetLog);
67 };
68 
69 
70 #endif
71