123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef QSLOGDEST_H
- #define QSLOGDEST_H
- #include "QsLogLevel.h"
- #include <QSharedPointer>
- #include <QtGlobal>
- class QString;
- class QObject;
- #ifdef QSLOG_IS_SHARED_LIBRARY
- #define QSLOG_SHARED_OBJECT Q_DECL_EXPORT
- #elif QSLOG_IS_SHARED_LIBRARY_IMPORT
- #define QSLOG_SHARED_OBJECT Q_DECL_IMPORT
- #else
- #define QSLOG_SHARED_OBJECT
- #endif
- namespace QsLogging
- {
- class QSLOG_SHARED_OBJECT Destination
- {
- public:
- typedef void (*LogFunction)(const QString &message, Level level);
- virtual void rotate() = 0;
- public:
- virtual ~Destination();
- virtual void write(const QString& message, Level level) = 0;
- virtual bool isValid() = 0;
- };
- typedef QSharedPointer<Destination> DestinationPtr;
- enum LogRotationOption
- {
- DisableLogRotation = 0,
- EnableLogRotation = 1,
- EnableLogRotationOnOpen = 2,
- };
- struct QSLOG_SHARED_OBJECT MaxSizeBytes
- {
- MaxSizeBytes() : size(0) {}
- explicit MaxSizeBytes(qint64 size_) : size(size_) {}
- qint64 size;
- };
- struct QSLOG_SHARED_OBJECT MaxOldLogCount
- {
- MaxOldLogCount() : count(0) {}
- explicit MaxOldLogCount(int count_) : count(count_) {}
- int count;
- };
- class QSLOG_SHARED_OBJECT DestinationFactory
- {
- public:
- static DestinationPtr MakeFileDestination(const QString& filePath,
- LogRotationOption rotation = DisableLogRotation,
- const MaxSizeBytes &sizeInBytesToRotateAfter = MaxSizeBytes(),
- const MaxOldLogCount &oldLogsToKeep = MaxOldLogCount());
- static DestinationPtr MakeDebugOutputDestination();
-
- static DestinationPtr MakeFunctorDestination(Destination::LogFunction f);
-
- static DestinationPtr MakeFunctorDestination(QObject *receiver, const char *member);
- };
- }
- #endif
|