summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/logger
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/logger')
-rw-r--r--rbutil/rbutilqt/logger/AbstractAppender.cpp58
-rw-r--r--rbutil/rbutilqt/logger/AbstractAppender.h125
-rw-r--r--rbutil/rbutilqt/logger/AbstractStringAppender.cpp161
-rw-r--r--rbutil/rbutilqt/logger/AbstractStringAppender.h116
-rw-r--r--rbutil/rbutilqt/logger/ConsoleAppender.cpp25
-rw-r--r--rbutil/rbutilqt/logger/ConsoleAppender.h32
-rw-r--r--rbutil/rbutilqt/logger/CuteLogger_global.h12
-rw-r--r--rbutil/rbutilqt/logger/FileAppender.cpp85
-rw-r--r--rbutil/rbutilqt/logger/FileAppender.h63
-rw-r--r--rbutil/rbutilqt/logger/LICENSE.LGPL504
-rw-r--r--rbutil/rbutilqt/logger/Logger.cpp370
-rw-r--r--rbutil/rbutilqt/logger/Logger.h319
-rw-r--r--rbutil/rbutilqt/logger/OutputDebugAppender.cpp31
-rw-r--r--rbutil/rbutilqt/logger/OutputDebugAppender.h33
-rw-r--r--rbutil/rbutilqt/logger/README.ROCKBOX7
15 files changed, 1941 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
21AbstractAppender::AbstractAppender()
22 : m_detailsLevel(Logger::Debug)
23{}
24
25
26AbstractAppender::~AbstractAppender()
27{}
28
29
30Logger::LogLevel AbstractAppender::detailsLevel() const
31{
32 QMutexLocker locker(&m_detailsLevelMutex);
33 return m_detailsLevel;
34}
35
36
37void AbstractAppender::setDetailsLevel(Logger::LogLevel level)
38{
39 QMutexLocker locker(&m_detailsLevelMutex);
40 m_detailsLevel = level;
41}
42
43
44void AbstractAppender::setDetailsLevel(const QString& level)
45{
46 setDetailsLevel(Logger::levelFromString(level));
47}
48
49
50void 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}
diff --git a/rbutil/rbutilqt/logger/AbstractAppender.h b/rbutil/rbutilqt/logger/AbstractAppender.h
new file mode 100644
index 0000000000..df1df4957c
--- /dev/null
+++ b/rbutil/rbutilqt/logger/AbstractAppender.h
@@ -0,0 +1,125 @@
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 ABSTRACTAPPENDER_H
15#define ABSTRACTAPPENDER_H
16
17// Local
18#include "CuteLogger_global.h"
19#include <Logger.h>
20
21// Qt
22#include <QMutex>
23
24//! The AbstractAppender class provides an abstract base class for writing a log entries.
25/**
26 * The AbstractAppender class is the base interface class for all log appenders that could be used with Logger.
27 *
28 * AbstractAppender provides a common implementation for the thread safe, mutex-protected logging of application
29 * messages, such as ConsoleAppender, FileAppender or something else. AbstractAppender is abstract and can not be
30 * instantiated, but you can use any of its subclasses or create a custom log appender at your choice.
31 *
32 * Appenders are the logical devices that is aimed to be attached to Logger object by calling
33 * Logger::registerAppender(). On each log record call from the application Logger object sequentially calls write()
34 * function on all the appenders registered in it.
35 *
36 * You can subclass AbstractAppender to implement a logging target of any kind you like. It may be the external logging
37 * subsystem (for example, syslog in *nix), XML file, SQL database entries, D-Bus messages or anything else you can
38 * imagine.
39 *
40 * For the simple non-structured plain text logging (for example, to a plain text file or to the console output) you may
41 * like to subclass the AbstractStringAppender instead of AbstractAppender, which will give you a more convinient way to
42 * control the format of the log output.
43 *
44 * \sa AbstractStringAppender
45 * \sa Logger::registerAppender()
46 */
47class CUTELOGGERSHARED_EXPORT AbstractAppender
48{
49 public:
50 //! Constructs a AbstractAppender object.
51 AbstractAppender();
52
53 //! Destructs the AbstractAppender object.
54 virtual ~AbstractAppender();
55
56 //! Returns the current details level of appender.
57 /**
58 * Log records with a log level lower than a current detailsLevel() will be silently ignored by appender and would not
59 * be sent to its append() function.
60 *
61 * It provides additional logging flexibility, allowing you to set the different severity levels for different types
62 * of logs.
63 *
64 * \note This function is thread safe.
65 *
66 * \sa setDetailsLevel()
67 * \sa Logger::LogLevel
68 */
69 Logger::LogLevel detailsLevel() const;
70
71 //! Sets the current details level of appender.
72 /**
73 * \note This function is thread safe.
74 *
75 * \sa detalsLevel()
76 * \sa Logger::LogLevel
77 */
78 void setDetailsLevel(Logger::LogLevel level);
79
80 //! Sets the current details level of appender
81 /**
82 * This function is provided for convinience, it behaves like an above function.
83 *
84 * \sa detalsLevel()
85 * \sa Logger::LogLevel
86 */
87 void setDetailsLevel(const QString& level);
88
89 //! Tries to write the log record to this logger
90 /**
91 * This is the function called by Logger object to write a log message to the appender.
92 *
93 * \note This function is thread safe.
94 *
95 * \sa Logger::write()
96 * \sa detailsLevel()
97 */
98 void write(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line, const char* function,
99 const QString& message);
100
101 protected:
102 //! Writes the log record to the logger instance
103 /**
104 * This function is called every time when user tries to write a message to this AbstractAppender instance using
105 * the write() function. Write function works as proxy and transfers only the messages with log level more or equal
106 * to the current logLevel().
107 *
108 * Overload this function when you are implementing a custom appender.
109 *
110 * \note This function is not needed to be thread safe because it is never called directly by Logger object. The
111 * write() function works as a proxy and protects this function from concurrent access.
112 *
113 * \sa Logger::write()
114 */
115 virtual void append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
116 const char* function, const QString& message) = 0;
117
118 private:
119 QMutex m_writeMutex;
120
121 Logger::LogLevel m_detailsLevel;
122 mutable QMutex m_detailsLevelMutex;
123};
124
125#endif // ABSTRACTAPPENDER_H
diff --git a/rbutil/rbutilqt/logger/AbstractStringAppender.cpp b/rbutil/rbutilqt/logger/AbstractStringAppender.cpp
new file mode 100644
index 0000000000..073ecb7782
--- /dev/null
+++ b/rbutil/rbutilqt/logger/AbstractStringAppender.cpp
@@ -0,0 +1,161 @@
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 "AbstractStringAppender.h"
16
17// Qt
18#include <QReadLocker>
19#include <QWriteLocker>
20#include <QDateTime>
21#include <QRegExp>
22
23const char formattingMarker = '%';
24
25AbstractStringAppender::AbstractStringAppender()
26 : m_format(QLatin1String("%t{yyyy-MM-ddTHH:mm:ss.zzz} [%-7l] <%c> %m\n"))
27{}
28
29
30QString AbstractStringAppender::format() const
31{
32 QReadLocker locker(&m_formatLock);
33 return m_format;
34}
35
36
37void AbstractStringAppender::setFormat(const QString& format)
38{
39 QWriteLocker locker(&m_formatLock);
40 m_format = format;
41}
42
43
44QString AbstractStringAppender::stripFunctionName(const char* name)
45{
46 QRegExp rx("^.+\\s((?:[\\w\\d]+::)+)?([\\w\\d\\<\\>~]+)(?:\\(.*\\)).*$"); // XXX: SLOW!
47 return QString::fromLatin1(name).replace(rx, QString(QLatin1String("\\1\\2")));
48}
49
50
51QString AbstractStringAppender::formattedString(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file,
52 int line, const char* function, const QString& message) const
53{
54 QString f = format();
55 const int size = f.size();
56
57 QString result;
58
59 int i = 0;
60 while (i < f.size())
61 {
62 QChar c = f.at(i);
63
64 // We will silently ignore the broken % marker at the end of string
65 if (c != QLatin1Char(formattingMarker) || (i + 1) == size)
66 {
67 result.append(c);
68 }
69 else
70 {
71 QChar command = f.at(++i);
72
73 // Check for the padding instruction
74 int fieldWidth = 0;
75 if (command.isDigit() || command.category() == QChar::Punctuation_Dash)
76 {
77 int j = 1;
78 while ((i + j) < size && f.at(i + j).isDigit())
79 j++;
80 fieldWidth = f.mid(i, j).toInt();
81
82 i += j;
83 command = f.at(i);
84 }
85
86 // Log record chunk to insert instead of formatting instruction
87 QString chunk;
88
89 // Time stamp
90 if (command == QLatin1Char('t'))
91 {
92 if (f.at(i + 1) == QLatin1Char('{'))
93 {
94 int j = 1;
95 while ((i + 2 + j) < size && f.at(i + 2 + j) != QLatin1Char('}'))
96 j++;
97
98 if ((i + 2 + j) < size)
99 {
100 chunk = timeStamp.toString(f.mid(i + 2, j));
101
102 i += j;
103 i += 2;
104 }
105 }
106
107 if (chunk.isNull())
108 chunk = timeStamp.toString(QLatin1String("HH:mm:ss.zzz"));
109 }
110
111 // Log level
112 else if (command == QLatin1Char('l'))
113 chunk = Logger::levelToString(logLevel);
114
115 // Uppercased log level
116 else if (command == QLatin1Char('L'))
117 chunk = Logger::levelToString(logLevel).toUpper();
118
119 // Filename
120 else if (command == QLatin1Char('F'))
121 chunk = QLatin1String(file);
122
123 // Filename without a path
124 else if (command == QLatin1Char('f'))
125 chunk = QString(QLatin1String(file)).section('/', -1);
126
127 // Source line number
128 else if (command == QLatin1Char('i'))
129 chunk = QString::number(line);
130
131 // Function name, as returned by Q_FUNC_INFO
132 else if (command == QLatin1Char('C'))
133 chunk = QString::fromLatin1(function);
134
135 // Stripped function name
136 else if (command == QLatin1Char('c'))
137 chunk = stripFunctionName(function);
138
139 // Log message
140 else if (command == QLatin1Char('m'))
141 chunk = message;
142
143 // We simply replace the double formatting marker (%) with one
144 else if (command == QLatin1Char(formattingMarker))
145 chunk = QLatin1Char(formattingMarker);
146
147 // Do not process any unknown commands
148 else
149 {
150 chunk = QLatin1Char(formattingMarker);
151 chunk.append(command);
152 }
153
154 result.append(QString(QLatin1String("%1")).arg(chunk, fieldWidth));
155 }
156
157 ++i;
158 }
159
160 return result;
161}
diff --git a/rbutil/rbutilqt/logger/AbstractStringAppender.h b/rbutil/rbutilqt/logger/AbstractStringAppender.h
new file mode 100644
index 0000000000..3cef63bff9
--- /dev/null
+++ b/rbutil/rbutilqt/logger/AbstractStringAppender.h
@@ -0,0 +1,116 @@
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 ABSTRACTSTRINGAPPENDER_H
15#define ABSTRACTSTRINGAPPENDER_H
16
17// Local
18#include "CuteLogger_global.h"
19#include <AbstractAppender.h>
20
21// Qt
22#include <QReadWriteLock>
23
24
25//! The AbstractStringAppender class provides a convinient base for appenders working with plain text formatted logs.
26/**
27 * AbstractSringAppender is the simple extension of the AbstractAppender class providing the convinient way to create
28 * custom log appenders working with a plain text formatted log targets.
29 *
30 * It have the formattedString() protected function that formats the logging arguments according to a format set with
31 * setFormat().
32 *
33 * This class can not be directly instantiated because it contains pure virtual function inherited from AbstractAppender
34 * class.
35 *
36 * For more detailed description of customizing the log output format see the documentation on the setFormat() function.
37 */
38class CUTELOGGERSHARED_EXPORT AbstractStringAppender : public AbstractAppender
39{
40 public:
41 //! Constructs a new string appender object
42 AbstractStringAppender();
43
44 //! Returns the current log format string.
45 /**
46 * The default format is set to "%t{yyyy-MM-ddTHH:mm:ss.zzz} [%-7l] <%C> %m\n". You can set a different log record
47 * format using the setFormat() function.
48 *
49 * \sa setFormat(const QString&)
50 */
51 QString format() const;
52
53 //! Sets the logging format for writing strings to the log target with this appender.
54 /**
55 * The string format seems to be very common to those developers who have used a standart sprintf function.
56 *
57 * Log output format is a simple QString with the special markers (starting with % sign) which will be replaced with
58 * it's internal meaning when writing a log record.
59 *
60 * Controlling marker begins with the percent sign (%) which is followed by (optional) field width argument, the
61 * (necessary) single-letter command (which describes, what will be put to log record instead of marker, and an
62 * additional formatting argument (in the {} brackets) supported for some of the log commands.
63 *
64 * Field width argument works almost identically to the \c QString::arg() \c fieldWidth argument (and uses it
65 * internally). For example, \c "%-7l" will be replaced with the left padded debug level of the message
66 * (\c "Debug ") or something. For the more detailed description of it you may consider to look to the Qt
67 * Reference Documentation.
68 *
69 * Supported marker commands are:
70 * \arg \c %t - timestamp. You may specify your custom timestamp format using the {} brackets after the marker,
71 * timestamp format here will be similiar to those used in QDateTime::toString() function. For example,
72 * "%t{dd-MM-yyyy, HH:mm}" may be replaced with "17-12-2010, 20:17" depending on current date and time.
73 * The default format used here is "HH:mm:ss.zzz".
74 * \arg \c %l - Log level. Possible log levels are shown in the Logger::LogLevel enumerator.
75 * \arg \c %L - Uppercased log level.
76 * \arg \c %F - Full source file name (with path) of the file that requested log recording. Uses the \c __FILE__
77 * preprocessor macro.
78 * \arg \c %f - Short file name (with stripped path).
79 * \arg \c %i - Line number in the source file. Uses the \c __LINE__ preprocessor macro.
80 * \arg \c %C - Name of function that called on of the LOG_* macros. Uses the \c Q_FUNC_INFO macro provided with
81 * Qt.
82 * \arg \c %c - [EXPERIMENTAL] Similiar to the %C, but the function name is stripped using stripFunctionName
83 * \arg \c %m - The log message sent by the caller.
84 * \arg \c %% - Convinient marker that is replaced with the single \c % mark.
85 *
86 * \note Format doesn't add \c '\\n' to the end of the format line. Please consider adding it manually.
87 *
88 * \sa format()
89 * \sa stripFunctionName()
90 * \sa Logger::LogLevel
91 */
92 void setFormat(const QString&);
93
94 //! Strips the long function signature (as added by Q_FUNC_INFO macro)
95 /**
96 * The string processing drops the returning type, arguments and template parameters of function. It is definitely
97 * useful for enchancing the log output readability.
98 * \return stripped function name
99 */
100 static QString stripFunctionName(const char*);
101
102 protected:
103 //! Returns the string to record to the logging target, formatted according to the format().
104 /**
105 * \sa format()
106 * \sa setFormat(const QString&)
107 */
108 QString formattedString(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
109 const char* function, const QString& message) const;
110
111 private:
112 QString m_format;
113 mutable QReadWriteLock m_formatLock;
114};
115
116#endif // ABSTRACTSTRINGAPPENDER_H
diff --git a/rbutil/rbutilqt/logger/ConsoleAppender.cpp b/rbutil/rbutilqt/logger/ConsoleAppender.cpp
new file mode 100644
index 0000000000..da4a43c740
--- /dev/null
+++ b/rbutil/rbutilqt/logger/ConsoleAppender.cpp
@@ -0,0 +1,25 @@
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 "ConsoleAppender.h"
16
17// STL
18#include <iostream>
19
20
21void ConsoleAppender::append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
22 const char* function, const QString& message)
23{
24 std::cerr << qPrintable(formattedString(timeStamp, logLevel, file, line, function, message));
25}
diff --git a/rbutil/rbutilqt/logger/ConsoleAppender.h b/rbutil/rbutilqt/logger/ConsoleAppender.h
new file mode 100644
index 0000000000..fa685b5e82
--- /dev/null
+++ b/rbutil/rbutilqt/logger/ConsoleAppender.h
@@ -0,0 +1,32 @@
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 CONSOLEAPPENDER_H
15#define CONSOLEAPPENDER_H
16
17#include "CuteLogger_global.h"
18#include <AbstractStringAppender.h>
19
20//! ConsoleAppender is the simple appender that writes the log records to the std::cerr output stream.
21class CUTELOGGERSHARED_EXPORT ConsoleAppender : public AbstractStringAppender
22{
23 protected:
24 //! Writes the log record to the std::cerr stream.
25 /**
26 * \sa AbstractStringAppender::format()
27 */
28 virtual void append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
29 const char* function, const QString& message);
30};
31
32#endif // CONSOLEAPPENDER_H
diff --git a/rbutil/rbutilqt/logger/CuteLogger_global.h b/rbutil/rbutilqt/logger/CuteLogger_global.h
new file mode 100644
index 0000000000..43e74affdb
--- /dev/null
+++ b/rbutil/rbutilqt/logger/CuteLogger_global.h
@@ -0,0 +1,12 @@
1#ifndef CUTELOGGER_GLOBAL_H
2#define CUTELOGGER_GLOBAL_H
3
4#include <QtCore/qglobal.h>
5
6#if defined(CUTELOGGER_LIBRARY)
7# define CUTELOGGERSHARED_EXPORT Q_DECL_EXPORT
8#else
9# define CUTELOGGERSHARED_EXPORT Q_DECL_IMPORT
10#endif
11
12#endif // CUTELOGGER_GLOBAL_H
diff --git a/rbutil/rbutilqt/logger/FileAppender.cpp b/rbutil/rbutilqt/logger/FileAppender.cpp
new file mode 100644
index 0000000000..3e4d0e22f9
--- /dev/null
+++ b/rbutil/rbutilqt/logger/FileAppender.cpp
@@ -0,0 +1,85 @@
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 "FileAppender.h"
16
17// STL
18#include <iostream>
19
20
21FileAppender::FileAppender(const QString& fileName)
22{
23 setFileName(fileName);
24}
25
26
27FileAppender::~FileAppender()
28{
29 closeFile();
30}
31
32
33QString FileAppender::fileName() const
34{
35 QMutexLocker locker(&m_logFileMutex);
36 return m_logFile.fileName();
37}
38
39
40void FileAppender::setFileName(const QString& s)
41{
42 QMutexLocker locker(&m_logFileMutex);
43 if (m_logFile.isOpen())
44 m_logFile.close();
45
46 m_logFile.setFileName(s);
47}
48
49
50bool FileAppender::openFile()
51{
52 bool isOpen = false;
53 if (!m_logFile.isOpen())
54 {
55 if (m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
56 {
57 m_logStream.setDevice(&m_logFile);
58 isOpen = true;
59 }
60 else
61 {
62 std::cerr << "<FileAppender::append> Cannot open the log file " << qPrintable(m_logFile.fileName()) << std::endl;
63 }
64 }
65 return isOpen;
66}
67
68
69void FileAppender::append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
70 const char* function, const QString& message)
71{
72 QMutexLocker locker(&m_logFileMutex);
73
74 openFile();
75
76 m_logStream << formattedString(timeStamp, logLevel, file, line, function, message);
77 m_logStream.flush();
78 m_logFile.flush();
79}
80
81void FileAppender::closeFile()
82{
83 QMutexLocker locker(&m_logFileMutex);
84 m_logFile.close();
85}
diff --git a/rbutil/rbutilqt/logger/FileAppender.h b/rbutil/rbutilqt/logger/FileAppender.h
new file mode 100644
index 0000000000..70a70c3e43
--- /dev/null
+++ b/rbutil/rbutilqt/logger/FileAppender.h
@@ -0,0 +1,63 @@
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 "CuteLogger_global.h"
19#include <AbstractStringAppender.h>
20
21// Qt
22#include <QFile>
23#include <QTextStream>
24
25
26//! File is the simple appender that writes the log records to the plain text file.
27class CUTELOGGERSHARED_EXPORT FileAppender : public AbstractStringAppender
28{
29 public:
30 //! Constructs the new file appender assigned to file with the given name.
31 FileAppender(const QString& fileName = QString());
32 ~FileAppender();
33
34 //! Returns the name set by setFileName() or to the FileAppender constructor.
35 /**
36 * \sa setFileName()
37 */
38 QString fileName() const;
39
40 //! Sets the name of the file. The name can have no path, a relative path, or an absolute path.
41 /**
42 * \sa fileName()
43 */
44 void setFileName(const QString&);
45
46 protected:
47 //! Write the log record to the file.
48 /**
49 * \sa fileName()
50 * \sa AbstractStringAppender::format()
51 */
52 virtual void append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
53 const char* function, const QString& message);
54 bool openFile();
55 void closeFile();
56
57 private:
58 QFile m_logFile;
59 QTextStream m_logStream;
60 mutable QMutex m_logFileMutex;
61};
62
63#endif // FILEAPPENDER_H
diff --git a/rbutil/rbutilqt/logger/LICENSE.LGPL b/rbutil/rbutilqt/logger/LICENSE.LGPL
new file mode 100644
index 0000000000..5ab7695ab8
--- /dev/null
+++ b/rbutil/rbutilqt/logger/LICENSE.LGPL
@@ -0,0 +1,504 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 2.1, February 1999
3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9[This is the first released version of the Lesser GPL. It also counts
10 as the successor of the GNU Library Public License, version 2, hence
11 the version number 2.1.]
12
13 Preamble
14
15 The licenses for most software are designed to take away your
16freedom to share and change it. By contrast, the GNU General Public
17Licenses are intended to guarantee your freedom to share and change
18free software--to make sure the software is free for all its users.
19
20 This license, the Lesser General Public License, applies to some
21specially designated software packages--typically libraries--of the
22Free Software Foundation and other authors who decide to use it. You
23can use it too, but we suggest you first think carefully about whether
24this license or the ordinary General Public License is the better
25strategy to use in any particular case, based on the explanations below.
26
27 When we speak of free software, we are referring to freedom of use,
28not price. Our General Public Licenses are designed to make sure that
29you have the freedom to distribute copies of free software (and charge
30for this service if you wish); that you receive source code or can get
31it if you want it; that you can change the software and use pieces of
32it in new free programs; and that you are informed that you can do
33these things.
34
35 To protect your rights, we need to make restrictions that forbid
36distributors to deny you these rights or to ask you to surrender these
37rights. These restrictions translate to certain responsibilities for
38you if you distribute copies of the library or if you modify it.
39
40 For example, if you distribute copies of the library, whether gratis
41or for a fee, you must give the recipients all the rights that we gave
42you. You must make sure that they, too, receive or can get the source
43code. If you link other code with the library, you must provide
44complete object files to the recipients, so that they can relink them
45with the library after making changes to the library and recompiling
46it. And you must show them these terms so they know their rights.
47
48 We protect your rights with a two-step method: (1) we copyright the
49library, and (2) we offer you this license, which gives you legal
50permission to copy, distribute and/or modify the library.
51
52 To protect each distributor, we want to make it very clear that
53there is no warranty for the free library. Also, if the library is
54modified by someone else and passed on, the recipients should know
55that what they have is not the original version, so that the original
56author's reputation will not be affected by problems that might be
57introduced by others.
58
59 Finally, software patents pose a constant threat to the existence of
60any free program. We wish to make sure that a company cannot
61effectively restrict the users of a free program by obtaining a
62restrictive license from a patent holder. Therefore, we insist that
63any patent license obtained for a version of the library must be
64consistent with the full freedom of use specified in this license.
65
66 Most GNU software, including some libraries, is covered by the
67ordinary GNU General Public License. This license, the GNU Lesser
68General Public License, applies to certain designated libraries, and
69is quite different from the ordinary General Public License. We use
70this license for certain libraries in order to permit linking those
71libraries into non-free programs.
72
73 When a program is linked with a library, whether statically or using
74a shared library, the combination of the two is legally speaking a
75combined work, a derivative of the original library. The ordinary
76General Public License therefore permits such linking only if the
77entire combination fits its criteria of freedom. The Lesser General
78Public License permits more lax criteria for linking other code with
79the library.
80
81 We call this license the "Lesser" General Public License because it
82does Less to protect the user's freedom than the ordinary General
83Public License. It also provides other free software developers Less
84of an advantage over competing non-free programs. These disadvantages
85are the reason we use the ordinary General Public License for many
86libraries. However, the Lesser license provides advantages in certain
87special circumstances.
88
89 For example, on rare occasions, there may be a special need to
90encourage the widest possible use of a certain library, so that it becomes
91a de-facto standard. To achieve this, non-free programs must be
92allowed to use the library. A more frequent case is that a free
93library does the same job as widely used non-free libraries. In this
94case, there is little to gain by limiting the free library to free
95software only, so we use the Lesser General Public License.
96
97 In other cases, permission to use a particular library in non-free
98programs enables a greater number of people to use a large body of
99free software. For example, permission to use the GNU C Library in
100non-free programs enables many more people to use the whole GNU
101operating system, as well as its variant, the GNU/Linux operating
102system.
103
104 Although the Lesser General Public License is Less protective of the
105users' freedom, it does ensure that the user of a program that is
106linked with the Library has the freedom and the wherewithal to run
107that program using a modified version of the Library.
108
109 The precise terms and conditions for copying, distribution and
110modification follow. Pay close attention to the difference between a
111"work based on the library" and a "work that uses the library". The
112former contains code derived from the library, whereas the latter must
113be combined with the library in order to run.
114
115 GNU LESSER GENERAL PUBLIC LICENSE
116 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
118 0. This License Agreement applies to any software library or other
119program which contains a notice placed by the copyright holder or
120other authorized party saying it may be distributed under the terms of
121this Lesser General Public License (also called "this License").
122Each licensee is addressed as "you".
123
124 A "library" means a collection of software functions and/or data
125prepared so as to be conveniently linked with application programs
126(which use some of those functions and data) to form executables.
127
128 The "Library", below, refers to any such software library or work
129which has been distributed under these terms. A "work based on the
130Library" means either the Library or any derivative work under
131copyright law: that is to say, a work containing the Library or a
132portion of it, either verbatim or with modifications and/or translated
133straightforwardly into another language. (Hereinafter, translation is
134included without limitation in the term "modification".)
135
136 "Source code" for a work means the preferred form of the work for
137making modifications to it. For a library, complete source code means
138all the source code for all modules it contains, plus any associated
139interface definition files, plus the scripts used to control compilation
140and installation of the library.
141
142 Activities other than copying, distribution and modification are not
143covered by this License; they are outside its scope. The act of
144running a program using the Library is not restricted, and output from
145such a program is covered only if its contents constitute a work based
146on the Library (independent of the use of the Library in a tool for
147writing it). Whether that is true depends on what the Library does
148and what the program that uses the Library does.
149
150 1. You may copy and distribute verbatim copies of the Library's
151complete source code as you receive it, in any medium, provided that
152you conspicuously and appropriately publish on each copy an
153appropriate copyright notice and disclaimer of warranty; keep intact
154all the notices that refer to this License and to the absence of any
155warranty; and distribute a copy of this License along with the
156Library.
157
158 You may charge a fee for the physical act of transferring a copy,
159and you may at your option offer warranty protection in exchange for a
160fee.
161
162 2. You may modify your copy or copies of the Library or any portion
163of it, thus forming a work based on the Library, and copy and
164distribute such modifications or work under the terms of Section 1
165above, provided that you also meet all of these conditions:
166
167 a) The modified work must itself be a software library.
168
169 b) You must cause the files modified to carry prominent notices
170 stating that you changed the files and the date of any change.
171
172 c) You must cause the whole of the work to be licensed at no
173 charge to all third parties under the terms of this License.
174
175 d) If a facility in the modified Library refers to a function or a
176 table of data to be supplied by an application program that uses
177 the facility, other than as an argument passed when the facility
178 is invoked, then you must make a good faith effort to ensure that,
179 in the event an application does not supply such function or
180 table, the facility still operates, and performs whatever part of
181 its purpose remains meaningful.
182
183 (For example, a function in a library to compute square roots has
184 a purpose that is entirely well-defined independent of the
185 application. Therefore, Subsection 2d requires that any
186 application-supplied function or table used by this function must
187 be optional: if the application does not supply it, the square
188 root function must still compute square roots.)
189
190These requirements apply to the modified work as a whole. If
191identifiable sections of that work are not derived from the Library,
192and can be reasonably considered independent and separate works in
193themselves, then this License, and its terms, do not apply to those
194sections when you distribute them as separate works. But when you
195distribute the same sections as part of a whole which is a work based
196on the Library, the distribution of the whole must be on the terms of
197this License, whose permissions for other licensees extend to the
198entire whole, and thus to each and every part regardless of who wrote
199it.
200
201Thus, it is not the intent of this section to claim rights or contest
202your rights to work written entirely by you; rather, the intent is to
203exercise the right to control the distribution of derivative or
204collective works based on the Library.
205
206In addition, mere aggregation of another work not based on the Library
207with the Library (or with a work based on the Library) on a volume of
208a storage or distribution medium does not bring the other work under
209the scope of this License.
210
211 3. You may opt to apply the terms of the ordinary GNU General Public
212License instead of this License to a given copy of the Library. To do
213this, you must alter all the notices that refer to this License, so
214that they refer to the ordinary GNU General Public License, version 2,
215instead of to this License. (If a newer version than version 2 of the
216ordinary GNU General Public License has appeared, then you can specify
217that version instead if you wish.) Do not make any other change in
218these notices.
219
220 Once this change is made in a given copy, it is irreversible for
221that copy, so the ordinary GNU General Public License applies to all
222subsequent copies and derivative works made from that copy.
223
224 This option is useful when you wish to copy part of the code of
225the Library into a program that is not a library.
226
227 4. You may copy and distribute the Library (or a portion or
228derivative of it, under Section 2) in object code or executable form
229under the terms of Sections 1 and 2 above provided that you accompany
230it with the complete corresponding machine-readable source code, which
231must be distributed under the terms of Sections 1 and 2 above on a
232medium customarily used for software interchange.
233
234 If distribution of object code is made by offering access to copy
235from a designated place, then offering equivalent access to copy the
236source code from the same place satisfies the requirement to
237distribute the source code, even though third parties are not
238compelled to copy the source along with the object code.
239
240 5. A program that contains no derivative of any portion of the
241Library, but is designed to work with the Library by being compiled or
242linked with it, is called a "work that uses the Library". Such a
243work, in isolation, is not a derivative work of the Library, and
244therefore falls outside the scope of this License.
245
246 However, linking a "work that uses the Library" with the Library
247creates an executable that is a derivative of the Library (because it
248contains portions of the Library), rather than a "work that uses the
249library". The executable is therefore covered by this License.
250Section 6 states terms for distribution of such executables.
251
252 When a "work that uses the Library" uses material from a header file
253that is part of the Library, the object code for the work may be a
254derivative work of the Library even though the source code is not.
255Whether this is true is especially significant if the work can be
256linked without the Library, or if the work is itself a library. The
257threshold for this to be true is not precisely defined by law.
258
259 If such an object file uses only numerical parameters, data
260structure layouts and accessors, and small macros and small inline
261functions (ten lines or less in length), then the use of the object
262file is unrestricted, regardless of whether it is legally a derivative
263work. (Executables containing this object code plus portions of the
264Library will still fall under Section 6.)
265
266 Otherwise, if the work is a derivative of the Library, you may
267distribute the object code for the work under the terms of Section 6.
268Any executables containing that work also fall under Section 6,
269whether or not they are linked directly with the Library itself.
270
271 6. As an exception to the Sections above, you may also combine or
272link a "work that uses the Library" with the Library to produce a
273work containing portions of the Library, and distribute that work
274under terms of your choice, provided that the terms permit
275modification of the work for the customer's own use and reverse
276engineering for debugging such modifications.
277
278 You must give prominent notice with each copy of the work that the
279Library is used in it and that the Library and its use are covered by
280this License. You must supply a copy of this License. If the work
281during execution displays copyright notices, you must include the
282copyright notice for the Library among them, as well as a reference
283directing the user to the copy of this License. Also, you must do one
284of these things:
285
286 a) Accompany the work with the complete corresponding
287 machine-readable source code for the Library including whatever
288 changes were used in the work (which must be distributed under
289 Sections 1 and 2 above); and, if the work is an executable linked
290 with the Library, with the complete machine-readable "work that
291 uses the Library", as object code and/or source code, so that the
292 user can modify the Library and then relink to produce a modified
293 executable containing the modified Library. (It is understood
294 that the user who changes the contents of definitions files in the
295 Library will not necessarily be able to recompile the application
296 to use the modified definitions.)
297
298 b) Use a suitable shared library mechanism for linking with the
299 Library. A suitable mechanism is one that (1) uses at run time a
300 copy of the library already present on the user's computer system,
301 rather than copying library functions into the executable, and (2)
302 will operate properly with a modified version of the library, if
303 the user installs one, as long as the modified version is
304 interface-compatible with the version that the work was made with.
305
306 c) Accompany the work with a written offer, valid for at
307 least three years, to give the same user the materials
308 specified in Subsection 6a, above, for a charge no more
309 than the cost of performing this distribution.
310
311 d) If distribution of the work is made by offering access to copy
312 from a designated place, offer equivalent access to copy the above
313 specified materials from the same place.
314
315 e) Verify that the user has already received a copy of these
316 materials or that you have already sent this user a copy.
317
318 For an executable, the required form of the "work that uses the
319Library" must include any data and utility programs needed for
320reproducing the executable from it. However, as a special exception,
321the materials to be distributed need not include anything that is
322normally distributed (in either source or binary form) with the major
323components (compiler, kernel, and so on) of the operating system on
324which the executable runs, unless that component itself accompanies
325the executable.
326
327 It may happen that this requirement contradicts the license
328restrictions of other proprietary libraries that do not normally
329accompany the operating system. Such a contradiction means you cannot
330use both them and the Library together in an executable that you
331distribute.
332
333 7. You may place library facilities that are a work based on the
334Library side-by-side in a single library together with other library
335facilities not covered by this License, and distribute such a combined
336library, provided that the separate distribution of the work based on
337the Library and of the other library facilities is otherwise
338permitted, and provided that you do these two things:
339
340 a) Accompany the combined library with a copy of the same work
341 based on the Library, uncombined with any other library
342 facilities. This must be distributed under the terms of the
343 Sections above.
344
345 b) Give prominent notice with the combined library of the fact
346 that part of it is a work based on the Library, and explaining
347 where to find the accompanying uncombined form of the same work.
348
349 8. You may not copy, modify, sublicense, link with, or distribute
350the Library except as expressly provided under this License. Any
351attempt otherwise to copy, modify, sublicense, link with, or
352distribute the Library is void, and will automatically terminate your
353rights under this License. However, parties who have received copies,
354or rights, from you under this License will not have their licenses
355terminated so long as such parties remain in full compliance.
356
357 9. You are not required to accept this License, since you have not
358signed it. However, nothing else grants you permission to modify or
359distribute the Library or its derivative works. These actions are
360prohibited by law if you do not accept this License. Therefore, by
361modifying or distributing the Library (or any work based on the
362Library), you indicate your acceptance of this License to do so, and
363all its terms and conditions for copying, distributing or modifying
364the Library or works based on it.
365
366 10. Each time you redistribute the Library (or any work based on the
367Library), the recipient automatically receives a license from the
368original licensor to copy, distribute, link with or modify the Library
369subject to these terms and conditions. You may not impose any further
370restrictions on the recipients' exercise of the rights granted herein.
371You are not responsible for enforcing compliance by third parties with
372this License.
373
374 11. If, as a consequence of a court judgment or allegation of patent
375infringement or for any other reason (not limited to patent issues),
376conditions are imposed on you (whether by court order, agreement or
377otherwise) that contradict the conditions of this License, they do not
378excuse you from the conditions of this License. If you cannot
379distribute so as to satisfy simultaneously your obligations under this
380License and any other pertinent obligations, then as a consequence you
381may not distribute the Library at all. For example, if a patent
382license would not permit royalty-free redistribution of the Library by
383all those who receive copies directly or indirectly through you, then
384the only way you could satisfy both it and this License would be to
385refrain entirely from distribution of the Library.
386
387If any portion of this section is held invalid or unenforceable under any
388particular circumstance, the balance of the section is intended to apply,
389and the section as a whole is intended to apply in other circumstances.
390
391It is not the purpose of this section to induce you to infringe any
392patents or other property right claims or to contest validity of any
393such claims; this section has the sole purpose of protecting the
394integrity of the free software distribution system which is
395implemented by public license practices. Many people have made
396generous contributions to the wide range of software distributed
397through that system in reliance on consistent application of that
398system; it is up to the author/donor to decide if he or she is willing
399to distribute software through any other system and a licensee cannot
400impose that choice.
401
402This section is intended to make thoroughly clear what is believed to
403be a consequence of the rest of this License.
404
405 12. If the distribution and/or use of the Library is restricted in
406certain countries either by patents or by copyrighted interfaces, the
407original copyright holder who places the Library under this License may add
408an explicit geographical distribution limitation excluding those countries,
409so that distribution is permitted only in or among countries not thus
410excluded. In such case, this License incorporates the limitation as if
411written in the body of this License.
412
413 13. The Free Software Foundation may publish revised and/or new
414versions of the Lesser General Public License from time to time.
415Such new versions will be similar in spirit to the present version,
416but may differ in detail to address new problems or concerns.
417
418Each version is given a distinguishing version number. If the Library
419specifies a version number of this License which applies to it and
420"any later version", you have the option of following the terms and
421conditions either of that version or of any later version published by
422the Free Software Foundation. If the Library does not specify a
423license version number, you may choose any version ever published by
424the Free Software Foundation.
425
426 14. If you wish to incorporate parts of the Library into other free
427programs whose distribution conditions are incompatible with these,
428write to the author to ask for permission. For software which is
429copyrighted by the Free Software Foundation, write to the Free
430Software Foundation; we sometimes make exceptions for this. Our
431decision will be guided by the two goals of preserving the free status
432of all derivatives of our free software and of promoting the sharing
433and reuse of software generally.
434
435 NO WARRANTY
436
437 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
447 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456DAMAGES.
457
458 END OF TERMS AND CONDITIONS
459
460 How to Apply These Terms to Your New Libraries
461
462 If you develop a new library, and you want it to be of the greatest
463possible use to the public, we recommend making it free software that
464everyone can redistribute and change. You can do so by permitting
465redistribution under these terms (or, alternatively, under the terms of the
466ordinary General Public License).
467
468 To apply these terms, attach the following notices to the library. It is
469safest to attach them to the start of each source file to most effectively
470convey the exclusion of warranty; and each file should have at least the
471"copyright" line and a pointer to where the full notice is found.
472
473 <one line to give the library's name and a brief idea of what it does.>
474 Copyright (C) <year> <name of author>
475
476 This library is free software; you can redistribute it and/or
477 modify it under the terms of the GNU Lesser General Public
478 License as published by the Free Software Foundation; either
479 version 2.1 of the License, or (at your option) any later version.
480
481 This library is distributed in the hope that it will be useful,
482 but WITHOUT ANY WARRANTY; without even the implied warranty of
483 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 Lesser General Public License for more details.
485
486 You should have received a copy of the GNU Lesser General Public
487 License along with this library; if not, write to the Free Software
488 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489
490Also add information on how to contact you by electronic and paper mail.
491
492You should also get your employer (if you work as a programmer) or your
493school, if any, to sign a "copyright disclaimer" for the library, if
494necessary. Here is a sample; alter the names:
495
496 Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
499 <signature of Ty Coon>, 1 April 1990
500 Ty Coon, President of Vice
501
502That's all there is to it!
503
504
diff --git a/rbutil/rbutilqt/logger/Logger.cpp b/rbutil/rbutilqt/logger/Logger.cpp
new file mode 100644
index 0000000000..33ba50ec58
--- /dev/null
+++ b/rbutil/rbutilqt/logger/Logger.cpp
@@ -0,0 +1,370 @@
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 "Logger.h"
16#include "AbstractAppender.h"
17
18// Qt
19#include <QCoreApplication>
20#include <QReadWriteLock>
21#include <QSemaphore>
22#include <QDateTime>
23#include <QIODevice>
24#include <QTextCodec>
25
26// STL
27#include <iostream>
28
29
30class LogDevice : public QIODevice
31{
32 public:
33 LogDevice()
34 : m_semaphore(1)
35 {}
36
37 void lock(Logger::LogLevel logLevel, const char* file, int line, const char* function)
38 {
39 m_semaphore.acquire();
40
41 if (!isOpen())
42 open(QIODevice::WriteOnly);
43
44 m_logLevel = logLevel;
45 m_file = file;
46 m_line = line;
47 m_function = function;
48 }
49
50 protected:
51 qint64 readData(char*, qint64)
52 {
53 return 0;
54 }
55
56 qint64 writeData(const char* data, qint64 maxSize)
57 {
58 if (maxSize > 0)
59 Logger::write(m_logLevel, m_file, m_line, m_function, QString::fromLocal8Bit(QByteArray(data, maxSize)));
60
61 m_semaphore.release();
62 return maxSize;
63 }
64
65 private:
66 QSemaphore m_semaphore;
67 Logger::LogLevel m_logLevel;
68 const char* m_file;
69 int m_line;
70 const char* m_function;
71};
72
73
74// Forward declarations
75static void cleanupLoggerPrivate();
76
77#if QT_VERSION >= 0x050000
78static void qtLoggerMessageHandler(QtMsgType, const QMessageLogContext& context, const QString& msg);
79#else
80static void qtLoggerMessageHandler(QtMsgType type, const char* msg);
81#endif
82
83/**
84 * \internal
85 *
86 * LoggerPrivate class implements the Singleton pattern in a thread-safe way. It uses a static pointer to itself
87 * protected by QReadWriteLock
88 *
89 * The appender list inside the LoggerPrivate class is also protected by QReadWriteLock so this class could be safely
90 * used in a multi-threaded application.
91 */
92class LoggerPrivate
93{
94 public:
95 static LoggerPrivate* m_self;
96 static QReadWriteLock m_selfLock;
97
98 static LoggerPrivate* instance()
99 {
100 LoggerPrivate* result = 0;
101 {
102 QReadLocker locker(&m_selfLock);
103 result = m_self;
104 }
105
106 if (!result)
107 {
108 QWriteLocker locker(&m_selfLock);
109 m_self = new LoggerPrivate;
110
111#if QT_VERSION >= 0x050000
112 qInstallMessageHandler(qtLoggerMessageHandler);
113#else
114 qInstallMsgHandler(qtLoggerMessageHandler);
115#endif
116 qAddPostRoutine(cleanupLoggerPrivate);
117 result = m_self;
118 }
119
120 return result;
121 }
122
123
124 LoggerPrivate()
125 : m_logDevice(0)
126 {}
127
128
129 ~LoggerPrivate()
130 {
131 // Cleanup appenders
132 QReadLocker appendersLocker(&m_appendersLock);
133 foreach (AbstractAppender* appender, m_appenders)
134 delete appender;
135
136 // Cleanup device
137 QReadLocker deviceLocker(&m_logDeviceLock);
138 delete m_logDevice;
139 }
140
141
142 void registerAppender(AbstractAppender* appender)
143 {
144 QWriteLocker locker(&m_appendersLock);
145
146 if (!m_appenders.contains(appender))
147 m_appenders.append(appender);
148 else
149 std::cerr << "Trying to register appender that was already registered" << std::endl;
150 }
151
152
153 LogDevice* logDevice()
154 {
155 LogDevice* result = 0;
156 {
157 QReadLocker locker(&m_logDeviceLock);
158 result = m_logDevice;
159 }
160
161 if (!result)
162 {
163 QWriteLocker locker(&m_logDeviceLock);
164 m_logDevice = new LogDevice;
165 result = m_logDevice;
166 }
167
168 return result;
169 }
170
171
172 void write(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line, const char* function,
173 const QString& message)
174 {
175 QReadLocker locker(&m_appendersLock);
176
177 if (!m_appenders.isEmpty())
178 {
179 foreach (AbstractAppender* appender, m_appenders)
180 appender->write(timeStamp, logLevel, file, line, function, message);
181 }
182 else
183 {
184 // Fallback
185 QString result = QString(QLatin1String("[%1] <%2> %3")).arg(Logger::levelToString(logLevel), -7)
186 .arg(function).arg(message);
187
188 std::cerr << qPrintable(result) << std::endl;
189 }
190
191 if (logLevel == Logger::Fatal)
192 abort();
193 }
194
195
196 void write(Logger::LogLevel logLevel, const char* file, int line, const char* function, const QString& message)
197 {
198 write(QDateTime::currentDateTime(), logLevel, file, line, function, message);
199 }
200
201
202 void write(Logger::LogLevel logLevel, const char* file, int line, const char* function, const char* message)
203 {
204 write(logLevel, file, line, function, QString(message));
205 }
206
207
208 QDebug write(Logger::LogLevel logLevel, const char* file, int line, const char* function)
209 {
210 LogDevice* d = logDevice();
211 d->lock(logLevel, file, line, function);
212 return QDebug(d);
213 }
214
215
216 void writeAssert(const char* file, int line, const char* function, const char* condition)
217 {
218 write(Logger::Fatal, file, line, function, QString("ASSERT: \"%1\"").arg(condition));
219 }
220
221 private:
222 QList<AbstractAppender*> m_appenders;
223 QReadWriteLock m_appendersLock;
224
225 LogDevice* m_logDevice;
226 QReadWriteLock m_logDeviceLock;
227};
228
229// Static fields initialization
230LoggerPrivate* LoggerPrivate::m_self = 0;
231QReadWriteLock LoggerPrivate::m_selfLock;
232
233
234static void cleanupLoggerPrivate()
235{
236 QWriteLocker locker(&LoggerPrivate::m_selfLock);
237
238 delete LoggerPrivate::m_self;
239 LoggerPrivate::m_self = 0;
240}
241
242
243#if QT_VERSION >= 0x050000
244static void qtLoggerMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
245{
246 Logger::LogLevel level;
247 switch (type)
248 {
249 case QtDebugMsg:
250 level = Logger::Debug;
251 break;
252 case QtWarningMsg:
253 level = Logger::Warning;
254 break;
255 case QtCriticalMsg:
256 level = Logger::Error;
257 break;
258 case QtFatalMsg:
259 level = Logger::Fatal;
260 break;
261 }
262
263 Logger::write(level, context.file, context.line, context.function, msg);
264}
265
266#else
267
268static void qtLoggerMessageHandler(QtMsgType type, const char* msg)
269{
270 switch (type)
271 {
272 case QtDebugMsg:
273 LOG_DEBUG(msg);
274 break;
275 case QtWarningMsg:
276 LOG_WARNING(msg);
277 break;
278 case QtCriticalMsg:
279 LOG_ERROR(msg);
280 break;
281 case QtFatalMsg:
282 LOG_FATAL(msg);
283 break;
284 }
285}
286#endif
287
288
289QString Logger::levelToString(Logger::LogLevel logLevel)
290{
291 switch (logLevel)
292 {
293 case Trace:
294 return QLatin1String("Trace");
295 case Debug:
296 return QLatin1String("Debug");
297 case Info:
298 return QLatin1String("Info");
299 case Warning:
300 return QLatin1String("Warning");
301 case Error:
302 return QLatin1String("Error");
303 case Fatal:
304 return QLatin1String("Fatal");
305 }
306
307 return QString();
308}
309
310
311Logger::LogLevel Logger::levelFromString(const QString& s)
312{
313 QString str = s.trimmed().toLower();
314
315 LogLevel result = Debug;
316
317 if (str == QLatin1String("trace"))
318 result = Trace;
319 else if (str == QLatin1String("debug"))
320 result = Debug;
321 else if (str == QLatin1String("info"))
322 result = Info;
323 else if (str == QLatin1String("warning"))
324 result = Warning;
325 else if (str == QLatin1String("error"))
326 result = Error;
327 else if (str == QLatin1String("fatal"))
328 result = Fatal;
329
330 return result;
331}
332
333
334void Logger::registerAppender(AbstractAppender* appender)
335{
336 LoggerPrivate::instance()->registerAppender(appender);
337}
338
339
340void Logger::write(const QDateTime& timeStamp, LogLevel logLevel, const char* file, int line, const char* function,
341 const QString& message)
342{
343 LoggerPrivate::instance()->write(timeStamp, logLevel, file, line, function, message);
344}
345
346
347void Logger::write(LogLevel logLevel, const char* file, int line, const char* function, const QString& message)
348{
349 LoggerPrivate::instance()->write(logLevel, file, line, function, message);
350}
351
352
353void Logger::write(LogLevel logLevel, const char* file, int line, const char* function, const char* message, ...)
354{
355 va_list va;
356 va_start(va, message);
357 LoggerPrivate::instance()->write(logLevel, file, line, function, QString().vsprintf(message,va));
358 va_end(va);
359}
360
361QDebug Logger::write(LogLevel logLevel, const char* file, int line, const char* function)
362{
363 return LoggerPrivate::instance()->write(logLevel, file, line, function);
364}
365
366
367void Logger::writeAssert(const char* file, int line, const char* function, const char* condition)
368{
369 LoggerPrivate::instance()->writeAssert(file, line, function, condition);
370}
diff --git a/rbutil/rbutilqt/logger/Logger.h b/rbutil/rbutilqt/logger/Logger.h
new file mode 100644
index 0000000000..d056dfc25d
--- /dev/null
+++ b/rbutil/rbutilqt/logger/Logger.h
@@ -0,0 +1,319 @@
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 LOGGER_H
15#define LOGGER_H
16/**
17 * \file Logger.h
18 * \brief A file containing the description of Logger class and and additional useful macros for logging
19 */
20
21// Qt
22#include <QString>
23#include <QDebug>
24class QDateTime;
25
26// Local
27#include "CuteLogger_global.h"
28class AbstractAppender;
29
30
31//! Writes the trace log record
32/**
33 * This macro is the convinient way to call Logger::write(). It uses the common preprocessor macros \c __FILE__,
34 * \c __LINE__ and the standart Qt \c Q_FUNC_INFO macros to automatically determine the needed parameters to call
35 * Logger::write().
36 *
37 * \note This and other (LOG_INFO() etc...) macros uses the variadic macro arguments to give convinient usage form for
38 * the different versions of Logger::write() (using the QString or const char* argument or returning the QDebug class
39 * instance). Not all compilers will support this. Please, consider reviewing your compiler documentation to ensure
40 * it support __VA_ARGS__ macro.
41 *
42 * It is checked to work with GCC 4.4 or later.
43 *
44 * \sa Logger::LogLevel
45 * \sa Logger::write()
46 */
47#define LOG_TRACE(...) Logger::write(Logger::Trace, __FILE__, __LINE__, Q_FUNC_INFO, ##__VA_ARGS__)
48
49//! Writes the debug log record
50/**
51 * This macro records the info log record using the Logger::write() function. It works identically to the LOG_TRACE()
52 * macro.
53 *
54 * \sa LOG_TRACE()
55 * \sa Logger::LogLevel
56 * \sa Logger::write()
57 */
58#define LOG_DEBUG(...) Logger::write(Logger::Debug, __FILE__, __LINE__, Q_FUNC_INFO, ##__VA_ARGS__)
59
60//! Write the info log record
61/**
62 * This macro records the info log record using the Logger::write() function. It works identically to the LOG_TRACE()
63 * macro.
64 *
65 * \sa LOG_TRACE()
66 * \sa Logger::LogLevel
67 * \sa Logger::write()
68 */
69#define LOG_INFO(...) Logger::write(Logger::Info, __FILE__, __LINE__, Q_FUNC_INFO, ##__VA_ARGS__)
70
71//! Write the warning log record
72/**
73 * This macro records the warning log record using the Logger::write() function. It works identically to the LOG_TRACE()
74 * macro.
75 *
76 * \sa LOG_TRACE()
77 * \sa Logger::LogLevel
78 * \sa Logger::write()
79 */
80#define LOG_WARNING(...) Logger::write(Logger::Warning, __FILE__, __LINE__, Q_FUNC_INFO, ##__VA_ARGS__)
81
82//! Write the error log record
83/**
84 * This macro records the error log record using the Logger::write() function. It works identically to the LOG_TRACE()
85 * macro.
86 *
87 * \sa LOG_TRACE()
88 * \sa Logger::LogLevel
89 * \sa Logger::write()
90 */
91#define LOG_ERROR(...) Logger::write(Logger::Error, __FILE__, __LINE__, Q_FUNC_INFO, ##__VA_ARGS__)
92
93//! Write the fatal log record
94/**
95 * This macro records the fatal log record using the Logger::write() function. It works identically to the LOG_TRACE()
96 * macro.
97 *
98 * \note Recording of the log record using the Logger::Fatal log level will lead to calling the STL abort()
99 * function, which will interrupt the running of your software and begin the writing of the core dump.
100 *
101 * \sa LOG_TRACE()
102 * \sa Logger::LogLevel
103 * \sa Logger::write()
104 */
105#define LOG_FATAL(...) Logger::write(Logger::Fatal, __FILE__, __LINE__, Q_FUNC_INFO, ##__VA_ARGS__)
106
107//! Check the assertion
108/**
109 * This macro is a convinient and recommended to use way to call Logger::writeAssert() function. It uses the
110 * preprocessor macros (as the LOG_DEBUG() does) to fill the necessary arguments of the Logger::writeAssert() call. It
111 * also uses undocumented but rather mature and stable \c qt_noop() function (which does nothing) when the assertion
112 * is true.
113 *
114 * Example:
115 * \code
116 * bool b = checkSomething();
117 * ...
118 * LOG_ASSERT(b == true);
119 * \endcode
120 *
121 * \sa Logger::writeAssert()
122 */
123#define LOG_ASSERT(cond) ((!(cond)) ? Logger::writeAssert(__FILE__, __LINE__, Q_FUNC_INFO, #cond) : qt_noop())
124
125
126/**
127 * \mainpage
128 *
129 * Logger is a simple way to write the history of your application lifecycle to any target logging device (which is
130 * called Appender and may write to any target you will implement with it: console, text file, XML or something - you
131 * choose) and to map logging message to a class, function, source file and line of code which it is called from.
132 *
133 * Some simple appenders (which may be considered an examples) are provided with the logger itself: see ConsoleAppender
134 * and FileAppender documentation.
135 *
136 * It supports using it in a multithreaded applications, so ALL of its functions are thread safe.
137 *
138 * Simple usage example:
139 * \code
140 * #include <QCoreApplication>
141 *
142 * #include <Logger.h>
143 * #include <ConsoleAppender.h>
144 *
145 * int main(int argc, char* argv[])
146 * {
147 * QCoreApplication app(argc, argv);
148 * ...
149 * ConsoleAppender* consoleAppender = new ConsoleAppender();
150 * consoleAppender->setFormat("[%-7l] <%C> %m\n");
151 * Logger::registerAppender(consoleAppender);
152 * ...
153 * LOG_INFO("Starting the application");
154 * int result = app.exec();
155 * ...
156 * if (result)
157 * LOG_WARNING() << "Something went wrong." << "Result code is" << result;
158 *
159 * return result;
160 * }
161 * \endcode
162 *
163 * Logger internally uses the lazy-initialized singleton object and needs no definite initialization, but you may
164 * consider registering a log appender before calling any log recording functions or macros.
165 *
166 * The library design of Logger allows you to simply mass-replace all occurrences of qDebug and similiar calls with
167 * similiar Logger macros (e.g. LOG_DEBUG)
168 *
169 * \note Logger uses a singleton class which must live through all the application life cycle and cleans it on the
170 * destruction of the QCoreApplication (or QApplication) instance. It needs a QCoreApplication instance to be
171 * created before any of the Logger's functions are called.
172 *
173 * \sa AbstractAppender
174 * \sa LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL
175 * \sa LOG_ASSERT
176 */
177
178//! Very simple but rather powerful component which may be used for logging your application activities.
179class CUTELOGGERSHARED_EXPORT Logger
180{
181 public:
182 //! Describes the possible severity levels of the log records
183 enum LogLevel
184 {
185 Trace, //!< Trace level. Can be used for mostly unneeded records used for internal code tracing.
186 Debug, //!< Debug level. Useful for non-necessary records used for the debugging of the software.
187 Info, //!< Info level. Can be used for informational records, which may be interesting for not only developers.
188 Warning, //!< Warning. May be used to log some non-fatal warnings detected by your application.
189 Error, //!< Error. May be used for a big problems making your application work wrong but not crashing.
190 Fatal //!< Fatal. Used for unrecoverable errors, crashes the application right after the log record is written.
191 };
192
193 //! Converts the LogLevel enum value to its string representation
194 /**
195 * \param logLevel Log level to convert
196 *
197 * \sa LogLevel
198 * \sa levelFromString()
199 */
200 static QString levelToString(LogLevel logLevel);
201
202 //! Converts the LogLevel string representation to enum value
203 /**
204 * Comparation of the strings is case independent. If the log level string provided cannot be understood
205 * Logger::Debug is returned.
206 *
207 * \param s String to be decoded
208 *
209 * \sa LogLevel
210 * \sa levelToString()
211 */
212 static LogLevel levelFromString(const QString& s);
213
214 //! Registers the appender to write the log records to
215 /**
216 * On the log writing call (using one of the macros or the write() function) Logger traverses through the list of
217 * the appenders and writes a log records to the each of them. Please, look through the AbstractAppender
218 * documentation to understand the concept of appenders.
219 *
220 * If no appenders was added to Logger, it falls back to logging into the \c std::cerr STL stream.
221 *
222 * \param appender Appender to register in the Logger
223 *
224 * \note Logger takes ownership on the appender and it will delete it on the application exit. According to this,
225 * appenders must be created on heap to prevent double destruction of the appender.
226 *
227 * \sa AbstractAppender
228 */
229 static void registerAppender(AbstractAppender* appender);
230
231 //! Writes the log record
232 /**
233 * Writes the log records with the supplied arguments to all the registered appenders.
234 *
235 * \note It is not recommended to call this function directly. Instead of this you can just call one of the macros
236 * (LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL) that will supply all the needed
237 * information to this function.
238 *
239 * \param timeStamp - the time stamp of the record
240 * \param logLevel - the log level of the record
241 * \param file - the name of the source file that requested the log record
242 * \param line - the line of the code of source file that requested the log record
243 * \param function - name of the function that requested the log record
244 * \param message - log message
245 *
246 * \note Recording of the log record using the Logger::Fatal log level will lead to calling the STL abort()
247 * function, which will interrupt the running of your software and begin the writing of the core dump.
248 *
249 * \sa LogLevel
250 * \sa LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL
251 * \sa AbstractAppender
252 */
253 static void write(const QDateTime& timeStamp, LogLevel logLevel, const char* file, int line, const char* function,
254 const QString& message);
255
256 /**
257 * This is the overloaded function provided for the convinience. It behaves identically to the above function.
258 *
259 * This function uses the current timestamp obtained with \c QDateTime::currentDateTime().
260 *
261 * \sa write()
262 */
263 static void write(LogLevel logLevel, const char* file, int line, const char* function, const QString& message);
264
265 /**
266 * This is the overloaded function provided for the convinience. It behaves identically to the above function.
267 *
268 * This function uses the current timestamp obtained with \c QDateTime::currentDateTime(). Also it supports writing
269 * <tt>const char*</tt> instead of \c QString and converts it internally using the \c QString::fromAscii(). If you
270 * want this function to support the non-ascii strings, you will need to setup the codec using the
271 * \c QTextCodec::setCodecForCStrings()
272 *
273 * \sa write()
274 */
275 static void write(LogLevel logLevel, const char* file, int line, const char* function, const char* message, ...);
276
277 /**
278 * This is the overloaded function provided for the convinience. It behaves identically to the above function.
279 *
280 * This function doesn't accept any log message as argument. It returns the \c QDebug object that can be written
281 * using the stream functions. For example, you may like to write:
282 * \code
283 * LOG_DEBUG() << "This is the size" << size << "of the element" << elementName;
284 * \endcode
285 * instead of writing
286 * \code
287 * LOG_DEBUG(QString(QLatin1String("This is the size %1x%2 of the element %3"))
288 * .arg(size.x()).arg(size.y()).arg(elementName));
289 * \endcode
290 *
291 * Please consider reading the Qt Reference Documentation for the description of the QDebug class usage syntax.
292 *
293 * \note This overload is definitely more pleasant to use than the first write() overload, but it behaves definitely
294 * slower than all the above overloads.
295 *
296 * \sa write()
297 */
298 static QDebug write(LogLevel logLevel, const char* file, int line, const char* function);
299
300 //! Writes the assertion
301 /**
302 * This function writes the assertion record using the write() function.
303 *
304 * The assertion record is always written using the Logger::Fatal log level which leads to the abortation of the
305 * program and generation of the core dump (if supported).
306 *
307 * The message written to the appenders will be identical to the \c condition argument prefixed with the
308 * <tt>ASSERT:</tt> notification.
309 *
310 * \note It is not recommended to call this function directly. Instead of this you can just call the LOG_ASSERT
311 * macro that will supply all the needed information to this function.
312 *
313 * \sa LOG_ASSERT
314 * \sa write()
315 */
316 static void writeAssert(const char* file, int line, const char* function, const char* condition);
317};
318
319#endif // LOGGER_H
diff --git a/rbutil/rbutilqt/logger/OutputDebugAppender.cpp b/rbutil/rbutilqt/logger/OutputDebugAppender.cpp
new file mode 100644
index 0000000000..2d7facbd98
--- /dev/null
+++ b/rbutil/rbutilqt/logger/OutputDebugAppender.cpp
@@ -0,0 +1,31 @@
1/*
2 Copyright (c) 2010 Karl-Heinz Reichel (khreichel at googlemail 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 "OutputDebugAppender.h"
16
17// STL
18#include <windows.h>
19
20
21void OutputDebugAppender::append(const QDateTime& timeStamp,
22 Logger::LogLevel logLevel,
23 const char* file,
24 int line,
25 const char* function,
26 const QString& message)
27{
28 QString s = formattedString(timeStamp, logLevel, file, line, function, message);
29 OutputDebugStringW((LPCWSTR) s.utf16());
30}
31
diff --git a/rbutil/rbutilqt/logger/OutputDebugAppender.h b/rbutil/rbutilqt/logger/OutputDebugAppender.h
new file mode 100644
index 0000000000..f5a5b8c588
--- /dev/null
+++ b/rbutil/rbutilqt/logger/OutputDebugAppender.h
@@ -0,0 +1,33 @@
1/*
2 Copyright (c) 2010 Karl-Heinz Reichel (khreichel at googlemail 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
15#ifndef OUTPUTDEBUGAPPENDER_H
16#define OUTPUTDEBUGAPPENDER_H
17
18#include "CuteLogger_global.h"
19#include <AbstractStringAppender.h>
20
21//! OutputDebugAppender is the appender that writes the log records to the Microsoft Debug Log
22class CUTELOGGERSHARED_EXPORT OutputDebugAppender : public AbstractStringAppender
23{
24 protected:
25 //! Writes the log record to the windows debug log.
26 /**
27 * \sa AbstractStringAppender::format()
28 */
29 virtual void append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
30 const char* function, const QString& message);
31};
32
33#endif // OUTPUTDEBUGAPPENDER_H
diff --git a/rbutil/rbutilqt/logger/README.ROCKBOX b/rbutil/rbutilqt/logger/README.ROCKBOX
new file mode 100644
index 0000000000..08f537fb3f
--- /dev/null
+++ b/rbutil/rbutilqt/logger/README.ROCKBOX
@@ -0,0 +1,7 @@
1This folder contains the cutelogger project for logging functionality.
2These files are distributed under the LGPL v2 or later.
3The source files have been last synced with the projects at
4https://gitorious.org/cutelogger to commit
5e3c2745c6c5f38896f87472e01ea2caf2d9e211b.
6
7