| 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 |
#include "AbstractAppender.h" |
| 18 |
|
| 19 |
#include <QReadWriteLock> |
| 20 |
#include <QDateTime> |
| 21 |
|
| 22 |
DLOG_CORE_BEGIN_NAMESPACE |
| 23 |
|
| 24 |
class LIBDLOG_SHARED_EXPORT AbstractStringAppender : public AbstractAppender |
| 25 |
{ |
| 26 |
public: |
| 27 |
AbstractStringAppender(); |
| 28 |
virtual QString format() const; |
| 29 |
void setFormat(const QString &format); |
| 30 |
|
| 31 |
static QString stripFunctionName(const char *name); |
| 32 |
|
| 33 |
protected: |
| 34 |
QString formattedString(const QDateTime &time, Logger::LogLevel level, const char *file, int line, |
| 35 |
const char *func, const QString &category, const QString &msg) const; |
| 36 |
QString formattedString(const QDateTime &time, Logger::LogLevel level, const char *file, int line, |
| 37 |
const char *func, const QString &category, const QString &msg, bool withcolor) const; |
| 38 |
|
| 39 |
private: |
| 40 |
static QByteArray qCleanupFuncinfo(const char *); |
| 41 |
|
| 42 |
QString m_format; |
| 43 |
mutable QReadWriteLock m_formatLock; |
| 44 |
}; |
| 45 |
|
| 46 |
DLOG_CORE_END_NAMESPACE |
| 47 |
#endif // ABSTRACTSTRINGAPPENDER_H |