Debian Codegraph @

include/FileAppender.h

raw
1 /*
2 Copyright (c) 2010 Boris Moiseev (cyberbobs at gmail dot com)
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License version 2.1
6 as published by the Free Software Foundation and appearing in the file
7 LICENSE.LGPL included in the packaging of this file.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 */
14 #ifndef FILEAPPENDER_H
15 #define FILEAPPENDER_H
16
17 // Logger
18 #include "dlog_global.h"
19 #include "AbstractStringAppender.h"
20
21 // Qt
22 #include <QFile>
23 #include <QTextStream>
24
25 DLOG_CORE_BEGIN_NAMESPACE
26
27 class LIBDLOG_SHARED_EXPORT FileAppender : public AbstractStringAppender
28 {
29 public:
30 FileAppender(const QString &fileName = QString());
31 ~FileAppender();
32
33 QString fileName() const;
34 void setFileName(const QString &s);
35
36 qint64 size() const;
37
38 protected:
39 virtual void append(const QDateTime &time, Logger::LogLevel level, const char *file, int line,
40 const char *func, const QString &category, const QString &msg);
41 bool openFile();
42 void closeFile();
43
44 private:
45 QFile m_logFile;
46 QTextStream m_logStream;
47 mutable QMutex m_logFileMutex;
48 };
49
50 DLOG_CORE_END_NAMESPACE
51
52 #endif // FILEAPPENDER_H