snorenotify/src/core/log.h

95 lines
2.2 KiB
C
Raw Normal View History

2014-01-20 00:17:57 +00:00
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
2014-02-03 11:57:30 +00:00
#ifndef SNORELOG_H
#define SNORELOG_H
2014-01-20 00:17:57 +00:00
#include <QDebug>
#include "snore_exports.h"
2014-02-04 12:37:18 +00:00
/**
* @file
*/
/**
* SnoreDebugLevels enumerates all possible debugg levels.
*/
enum SnoreDebugLevels {
2014-02-04 12:37:18 +00:00
/**
* The most important messages, will be diplayed if the debug level >= 1
*/
SNORE_WARNING = 1,
/**
* Information messages, will be diplayed if the debug level >= 2
*/
SNORE_INFO = 2,
/**
* Debug messages will be diplayed if the debug level >= 3
*/
SNORE_DEBUG = 3
};
/**
* Logg macro use to logg messages.
* snoreDebug( SNORE_DEBUG ) << "Message" << notification;
*/
2014-02-05 16:15:50 +00:00
#if !defined(QT_NO_DEBUG_OUTPUT)
2014-02-04 12:37:18 +00:00
#define snoreDebug(X) Snore::SnoreLog( X ) << Q_FUNC_INFO
2014-02-05 16:15:50 +00:00
#else
#define snoreDebug(X) QNoDebug()
#endif
2014-02-04 12:37:18 +00:00
2014-01-20 00:17:57 +00:00
namespace Snore
{
2014-02-04 12:37:18 +00:00
/**
* SnoreLog is a helper class to provide a logging system to Snore.
* @author Patrick von Reth \<vonreth at kde.org\>
*/
2014-02-03 11:57:30 +00:00
class SNORE_EXPORT SnoreLog : public QDebug
2014-01-20 00:17:57 +00:00
{
2014-02-04 12:37:18 +00:00
2014-01-20 00:17:57 +00:00
public:
2014-02-04 12:37:18 +00:00
/**
* Creates a debugg message whith a priority lvl.
* Use the snoreDebug(lvl) macro for logging.<br>
* snoreDebug( SNORE_DEBUG ) << "Message" << notification;
* @param lvl
*/
SnoreLog(SnoreDebugLevels lvl);
2014-02-03 11:57:30 +00:00
~SnoreLog();
2014-01-20 00:17:57 +00:00
2014-02-04 12:37:18 +00:00
/**
* Sets the debug threshold
* @param lvl the debug level
*/
static void setDebugLvl(int lvl);
2014-02-05 16:15:50 +00:00
private:
2014-02-04 12:37:18 +00:00
SnoreDebugLevels m_lvl;
2014-01-20 00:17:57 +00:00
QString m_msg;
};
2014-02-05 16:15:50 +00:00
2014-01-20 00:17:57 +00:00
}
2014-02-03 11:57:30 +00:00
#endif // SNORELOG_H