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 13:44:03 +00:00
|
|
|
|
|
|
|
|
2014-02-04 12:37:18 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SnoreDebugLevels enumerates all possible debugg levels.
|
|
|
|
*/
|
|
|
|
enum SnoreDebugLevels
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
*/
|
|
|
|
#define snoreDebug(X) Snore::SnoreLog( X ) << Q_FUNC_INFO
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
private:
|
2014-01-20 00:17:57 +00:00
|
|
|
static inline int debugLvl()
|
|
|
|
{
|
2014-01-20 08:23:38 +00:00
|
|
|
if(s_debugLevel == -1)
|
|
|
|
{
|
|
|
|
s_debugLevel = qgetenv("SNORE_DEBUG_LVL").toInt();
|
|
|
|
}
|
2014-01-20 08:06:37 +00:00
|
|
|
return s_debugLevel;
|
2014-01-20 00:17:57 +00:00
|
|
|
}
|
|
|
|
|
2014-01-20 08:06:37 +00:00
|
|
|
|
|
|
|
static int s_debugLevel;
|
2014-02-04 12:37:18 +00:00
|
|
|
SnoreDebugLevels m_lvl;
|
2014-01-20 00:17:57 +00:00
|
|
|
QString m_msg;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-02-04 12:37:18 +00:00
|
|
|
|
2014-02-03 11:57:30 +00:00
|
|
|
#endif // SNORELOG_H
|