diff options
Diffstat (limited to 'rbutil/rbutilqt/logger/AbstractAppender.cpp')
-rw-r--r-- | rbutil/rbutilqt/logger/AbstractAppender.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/logger/AbstractAppender.cpp b/rbutil/rbutilqt/logger/AbstractAppender.cpp new file mode 100644 index 0000000000..de86b930d0 --- /dev/null +++ b/rbutil/rbutilqt/logger/AbstractAppender.cpp | |||
@@ -0,0 +1,58 @@ | |||
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 | // Local | ||
15 | #include "AbstractAppender.h" | ||
16 | |||
17 | // Qt | ||
18 | #include <QMutexLocker> | ||
19 | |||
20 | |||
21 | AbstractAppender::AbstractAppender() | ||
22 | : m_detailsLevel(Logger::Debug) | ||
23 | {} | ||
24 | |||
25 | |||
26 | AbstractAppender::~AbstractAppender() | ||
27 | {} | ||
28 | |||
29 | |||
30 | Logger::LogLevel AbstractAppender::detailsLevel() const | ||
31 | { | ||
32 | QMutexLocker locker(&m_detailsLevelMutex); | ||
33 | return m_detailsLevel; | ||
34 | } | ||
35 | |||
36 | |||
37 | void AbstractAppender::setDetailsLevel(Logger::LogLevel level) | ||
38 | { | ||
39 | QMutexLocker locker(&m_detailsLevelMutex); | ||
40 | m_detailsLevel = level; | ||
41 | } | ||
42 | |||
43 | |||
44 | void AbstractAppender::setDetailsLevel(const QString& level) | ||
45 | { | ||
46 | setDetailsLevel(Logger::levelFromString(level)); | ||
47 | } | ||
48 | |||
49 | |||
50 | void AbstractAppender::write(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line, | ||
51 | const char* function, const QString& message) | ||
52 | { | ||
53 | if (logLevel >= detailsLevel()) | ||
54 | { | ||
55 | QMutexLocker locker(&m_writeMutex); | ||
56 | append(timeStamp, logLevel, file, line, function, message); | ||
57 | } | ||
58 | } | ||