TreeFrogFramework: src/tlogger.h Source File

1#pragma once

2#include <QString>

3#include <QVariant>

4#include <TGlobal>

5#include <TLog>

6#include <QStringEncoder>

7

9class QTextCodec;

10

11namespace Tf {

12

15

16}

17

18

20public:

23 virtual QString key() const = 0;

25 virtual bool open() = 0;

27 virtual bool isOpen() const = 0;

28 virtual void log(const QByteArray &) = 0;

29 virtual void log(const TLog &tlog) { log(logToByteArray(tlog)); }

31 virtual QByteArray logToByteArray(const TLog &log) const;

32

33 const QByteArray &layout() const;

34 const QByteArray &dateTimeFormat() const;

36 const QString &target() const;

37

38 static QByteArray logToByteArray(const TLog &log, const QByteArray &layout, const QByteArray &dateTimeFormat, QStringConverter::Encoding encoding = QStringConverter::Utf8);

39 static QByteArray priorityToString(Tf::LogPriority priority);

40

41protected:

42 QStringConverter::Encoding encoding() const;

43 QVariant settingsValue(const QString &key, const QVariant &defaultValue = QVariant()) const;

44

45private:

47 mutable QString _target;

48 mutable std::optional<QStringConverter::Encoding> _encoding;

49};

The TLog class contains log messages for web application.

Definition tlog.h:9

The TLogger class provides an abstract base of logging functionality.

Definition tlogger.h:19

virtual void flush()

Flushes any buffered data to the device.

Definition tlogger.h:30

virtual ~TLogger()

Definition tlogger.h:22

virtual void close()=0

Closes the device.

virtual bool isMultiProcessSafe() const =0

Returns true if the implementation is guaranteed to be free of race conditions when accessed by multi...

virtual bool isOpen() const =0

Returns true if the device is open; otherwise returns false.

virtual void log(const TLog &tlog)

Writes the log log to the device.

Definition tlogger.h:29

virtual QString key() const =0

Returns a key that this logger plugin supports.

virtual bool open()=0

Opens the device for logging.

virtual void log(const QByteArray &)=0

The Tf namespace contains miscellaneous identifiers used throughout the library of TreeFrog Framework...

Definition tdebug.h:10

T_CORE_EXPORT void setAppLogLayout(const QByteArray &layout)

Definition tlogger.cpp:34

T_CORE_EXPORT void setAppLogDateTimeFormat(const QByteArray &format)

Definition tlogger.cpp:40

LogPriority

Definition tfnamespace.h:230

#define T_CORE_EXPORT

Definition tdeclexport.h:28