TreeFrogFramework  1.18
tlogger.h
Go to the documentation of this file.
1 #ifndef TLOGGER_H
2 #define TLOGGER_H
3 
4 #include <QString>
5 #include <QVariant>
6 #include <TGlobal>
7 #include <TLog>
8 
9 class TLog;
10 class QTextCodec;
11 
12 
14 {
15 public:
16  TLogger();
17  virtual ~TLogger() { }
18  virtual QString key() const = 0;
19  virtual bool isMultiProcessSafe() const = 0;
20  virtual bool open() = 0;
21  virtual void close() = 0;
22  virtual bool isOpen() const = 0;
23  virtual void log(const TLog &log) = 0; // thread safe log output
24  virtual void log(const QByteArray &) { } // thread safe log output
25  virtual void flush() { }
26  virtual QByteArray logToByteArray(const TLog &log) const;
27 
28  void readSettings();
29  const QByteArray &layout() const { return layout_; }
30  const QByteArray &dateTimeFormat() const { return dateTimeFormat_; }
31  Tf::LogPriority threshold() const { return threshold_; }
32  const QString &target() const { return target_; }
33  QVariant settingsValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
34 
35  static QByteArray logToByteArray(const TLog &log, const QByteArray &layout, const QByteArray &dateTimeFormat, QTextCodec *codec = 0);
36  static QByteArray priorityToString(Tf::LogPriority priority);
37 
38 protected:
39  QByteArray layout_;
40  QByteArray dateTimeFormat_;
42  QString target_;
43  QTextCodec *codec_;
44 };
45 
46 #endif // TLOGGER_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
The TLog class contains log messages for web application.
Definition: tlog.h:11
const QByteArray & dateTimeFormat() const
Returns a reference to the value for the setting datetime format.
Definition: tlogger.h:30
QString target_
Definition: tlogger.h:42
virtual ~TLogger()
Definition: tlogger.h:17
QByteArray layout_
Definition: tlogger.h:39
virtual void flush()
Flushes any buffered data to the device.
Definition: tlogger.h:25
QByteArray dateTimeFormat_
Definition: tlogger.h:40
LogPriority
Definition: tfnamespace.h:220
Tf::LogPriority threshold() const
Returns the value for the setting priority threshold.
Definition: tlogger.h:31
virtual void log(const QByteArray &)
Definition: tlogger.h:24
The TLogger class provides an abstract base of logging functionality.
Definition: tlogger.h:13
const QString & target() const
Returns a reference to the value for the setting target device.
Definition: tlogger.h:32
Tf::LogPriority threshold_
Definition: tlogger.h:41
const QByteArray & layout() const
Returns a reference to the value for the setting layout.
Definition: tlogger.h:29
QTextCodec * codec_
Definition: tlogger.h:43