log.h
1 //------------------------------------------------------------------------------
2 // log.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __LOG_H_
24 #define __LOG_H_
25 
26 #define gLog Log::instance
27 
28 #include "dptr.h"
29 #include "global.h"
30 #include <QMutex>
31 #include <QObject>
32 
37 class MAIN_EXPORT Log : public QObject
38 {
39  Q_OBJECT;
40 
41  public:
45  static Log instance;
46 
47  Log();
48  virtual ~Log();
49 
53  bool areTimestampsEnabled() const;
54 
58  const QString& content() const;
59 
66  bool isPrintingToStdout() const;
67 
68  void setPrintingToStdout(bool b);
69  void setTimestampsEnabled(bool b);
70 
74  Log& operator<<(const QString& string);
75 
76  public slots:
83  void addEntry(const QString& string);
84 
90  void addUnformattedEntry(const QString& string);
91 
95  void clearContent();
96 
97  signals:
103  void newEntry(const QString& entry);
104 
105  private:
106  DPtr<Log> d;
107 
108 };
109 
110 #endif
static Log instance
Global instance of the logger.
Definition: log.h:39
Log manager.
Definition: log.h:37