use new logging function

This commit is contained in:
Patrick von Reth 2014-01-20 01:22:56 +01:00
parent 8720c0c6d7
commit f1dab6aa55
17 changed files with 65 additions and 61 deletions

View File

@ -20,6 +20,7 @@ set ( SnoreNotify_SRCS ${SnoreNotify_SRCS}
alert.cpp
alert_p.cpp
hint.cpp
log.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${SNORENOTIFY_RCS}
)
@ -30,6 +31,7 @@ set ( SnoreNotify_HDR ${SnoreNotify_HDR}
application.h
alert.h
hint.h
log.h
snore_exports.h
version.h
)

View File

@ -109,7 +109,7 @@ void IconData::download()
{
if(!QFile(m_localUrl).exists())
{
qDebug() << "Downloading:" << m_url;
snoreDebug( SNORE_DEBUG ) << "Downloading:" << m_url;
QNetworkAccessManager manager;
QEventLoop loop;
QNetworkRequest request(m_url);

View File

@ -22,6 +22,7 @@
#include "notification/notification_p.h"
#include "notification/icon.h"
#include "../hint.h"
#include "../log.h"
#include <QSharedData>
@ -45,7 +46,7 @@ NotificationData::NotificationData (const Snore::Application &application, const
m_closeReason(NotificationEnums::CloseReasons::NONE)
{
notificationCount++;
qDebug()<< "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
snoreDebug( SNORE_DEBUG ) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
}
Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, NotificationEnums::Prioritys::prioritys priority):
@ -62,7 +63,7 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString
m_toReplace(old)
{
notificationCount++;
qDebug()<< "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
snoreDebug( SNORE_DEBUG )<< "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
}
NotificationData::~NotificationData()
@ -72,7 +73,7 @@ NotificationData::~NotificationData()
m_timeoutTimer->deleteLater();
}
notificationCount--;
qDebug() << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason;
snoreDebug( SNORE_DEBUG ) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason;
}

View File

@ -51,7 +51,7 @@ SnorePlugin *PluginContainer::load()
{
if ( !m_loader.load())
{
qDebug() << "Failed loading plugin: " << m_loader.errorString();
snoreDebug( SNORE_DEBUG ) << "Failed loading plugin: " << m_loader.errorString();
return NULL;
}
return qobject_cast<SnorePlugin*> ( m_loader.instance());
@ -109,33 +109,33 @@ const QStringList &PluginContainer::types()
void PluginContainer::updatePluginCache(){
qDebug() << "Updating plugin cache";
snoreDebug( SNORE_DEBUG ) << "Updating plugin cache";
s_pluginCache.clear();
cache().remove("");
foreach(const QString &type,PluginContainer::types()){
QDir plPath(SnoreCorePrivate::pluginDir().absoluteFilePath(type));
qDebug() << "Searching for plugins in" << plPath.path();
snoreDebug( SNORE_DEBUG ) << "Searching for plugins in" << plPath.path();
foreach (QString fileName, plPath.entryList(QDir::Files))
{
QString filepath(plPath.absoluteFilePath(fileName));
qDebug() << "adding" << filepath;
snoreDebug( SNORE_DEBUG ) << "adding" << filepath;
QPluginLoader loader(filepath);
QObject *plugin = loader.instance();
if (plugin == NULL) {
qDebug() << "Failed loading plugin: " << filepath << loader.errorString();
snoreDebug( SNORE_DEBUG ) << "Failed loading plugin: " << filepath << loader.errorString();
continue;
}
SnorePlugin *sp = qobject_cast<SnorePlugin*>(plugin);
if(sp == NULL){
qDebug() << "Error:" << fileName << " is not a Snore plugin" ;
snoreDebug( SNORE_DEBUG ) << "Error:" << fileName << " is not a Snore plugin" ;
loader.unload();
continue;
}
PluginContainer *info = new PluginContainer( SnoreCorePrivate::pluginDir().relativeFilePath(filepath),sp->name(),PluginContainer::typeFromString(type));
s_pluginCache.insert(info->name(),info);
qDebug() << "added" << info->name() << "to cache";
snoreDebug( SNORE_DEBUG ) << "added" << info->name() << "to cache";
}
}
cache().setValue("version",Version::revision());

View File

@ -36,7 +36,7 @@ SnorePlugin::SnorePlugin ( const QString &name ) :
SnorePlugin::~SnorePlugin()
{
qDebug() << m_name << this << "deleted";
snoreDebug( SNORE_DEBUG ) << m_name << this << "deleted";
deinitialize();
}
@ -47,7 +47,7 @@ bool SnorePlugin::initialize( SnoreCore *snore )
qFatal("Something went wrong, plugin %s is already initialized",this->name().toLatin1().constData());
return false;
}
qDebug() << "Initialize" << m_name << this << snore;
snoreDebug( SNORE_DEBUG ) << "Initialize" << m_name << this << snore;
this->m_snore = snore;
m_initialized = true;
return true;
@ -72,7 +72,7 @@ bool SnorePlugin::deinitialize()
{
if(m_initialized)
{
qDebug() << "Deinitialize" << m_name << this;
snoreDebug( SNORE_DEBUG ) << "Deinitialize" << m_name << this;
m_initialized = false;
return true;
}

View File

@ -41,7 +41,7 @@ SnoreBackend::SnoreBackend (const QString &name , bool canCloseNotification, boo
SnoreBackend::~SnoreBackend()
{
qDebug()<<"Deleting"<<name();
snoreDebug( SNORE_DEBUG )<<"Deleting"<<name();
}
@ -88,7 +88,7 @@ void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseRea
}
n.data()->setCloseReason(reason);
slotCloseNotification(n);
qDebug() << Q_FUNC_INFO << n;
snoreDebug( SNORE_DEBUG ) << n;
emit notificationClosed(n);
}
@ -111,7 +111,7 @@ SnoreSecondaryBackend::SnoreSecondaryBackend(const QString &name, bool supportsR
SnoreSecondaryBackend::~SnoreSecondaryBackend()
{
qDebug()<<"Deleting"<<name();
snoreDebug( SNORE_DEBUG )<<"Deleting"<<name();
}
bool SnoreSecondaryBackend::supportsRichtext()
@ -199,7 +199,7 @@ void SnoreBackend::notificationTimedOut()
Notification n = snore()->getActiveNotificationByID(timer->property("notificationID").toUInt());
if(n.isValid())
{
qDebug() << Q_FUNC_INFO << n;
snoreDebug( SNORE_DEBUG ) << n;
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
}
}

View File

@ -34,7 +34,7 @@ SnoreFrontend::SnoreFrontend ( const QString &name ) :
SnoreFrontend::~SnoreFrontend()
{
qDebug()<<"Deleting"<<name();
snoreDebug( SNORE_DEBUG )<<"Deleting"<<name();
}
}

View File

@ -54,7 +54,7 @@ SnoreCore::~SnoreCore()
void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
{
Q_D(SnoreCore);
qDebug() << "PluginInfo" << PluginContainer::pluginCache().keys();
snoreDebug( SNORE_DEBUG ) << "PluginInfo" << PluginContainer::pluginCache().keys();
foreach ( PluginContainer *info, PluginContainer::pluginCache().values())
{
if(types == SnorePlugin::ALL || types.testFlag(info->type()))
@ -63,7 +63,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
{
case SnorePlugin::BACKEND:
{
qDebug() << info->name() << "is a Notification_Backend";
snoreDebug( SNORE_DEBUG ) << info->name() << "is a Notification_Backend";
d->m_notificationBackends.append( info->name());
break;
}
@ -78,7 +78,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
}
case SnorePlugin::FRONTEND:
{
qDebug() << info->name() << "is a Notification_Frontend";
snoreDebug( SNORE_DEBUG ) << info->name() << "is a Notification_Frontend";
if(!info->load()->initialize( this )){
info->unload();
break;
@ -88,7 +88,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
}
case SnorePlugin::PLUGIN:
{
qDebug() <<info->name()<<"is a SnorePlugin";
snoreDebug( SNORE_DEBUG ) <<info->name()<<"is a SnorePlugin";
if(!info->load()->initialize(this)){
info->unload();
break;
@ -103,7 +103,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
}
}
}else{
qDebug()<<"dont load "<<info->file()<<info->type();
snoreDebug( SNORE_DEBUG )<<"dont load "<<info->file()<<info->type();
}
}
}
@ -111,7 +111,7 @@ void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
void SnoreCore::broadcastNotification ( Notification notification )
{
Q_D(SnoreCore);
qDebug()<<"Broadcasting"<<notification<<"timeout:"<<notification.timeout();
snoreDebug( SNORE_DEBUG )<<"Broadcasting"<<notification<<"timeout:"<<notification.timeout();
emit d->notify ( notification );
if ( d->m_notificationBackend != NULL )
{
@ -124,7 +124,7 @@ void SnoreCore::registerApplication(const Application &application)
Q_D(SnoreCore);
if(!d->m_applications.contains(application.name()))
{
qDebug() << Q_FUNC_INFO << "Registering Application:" << application;
snoreDebug( SNORE_DEBUG ) << "Registering Application:" << application;
d->m_applications.insert ( application.name(),application );
emit d->applicationRegistered ( application );
}
@ -167,16 +167,16 @@ bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
Q_D(SnoreCore);
if(!PluginContainer::pluginCache().contains(backend))
{
qDebug() << "Unknown Backend:" << backend;
snoreDebug( SNORE_DEBUG ) << "Unknown Backend:" << backend;
return false;
}
qDebug() << "Setting Notification Backend to:" << backend;
snoreDebug( SNORE_DEBUG ) << "Setting Notification Backend to:" << backend;
SnoreBackend* b = qobject_cast<SnoreBackend*>(PluginContainer::pluginCache()[backend]->load());
if(!b->isInitialized())
{
if(!b->initialize(this))
{
qDebug() << "Failed to initialize" << b->name();
snoreDebug( SNORE_DEBUG ) << "Failed to initialize" << b->name();
return false;
}
}

View File

@ -21,6 +21,7 @@
#define SNORESERVER_H
#include "snore_exports.h"
#include "log.h"
#include "application.h"
#include "notification/notification.h"
#include "plugins/plugins.h"

View File

@ -96,11 +96,11 @@ void FreedesktopBackend::slotNotify ( Notification noti )
noti.hints().setPrivateValue(this, "id", id.value());
m_dbusIdMap[id.value()] = noti.id();
qDebug() << Q_FUNC_INFO << noti.id() << "|" << id.value();
snoreDebug( SNORE_DEBUG ) << noti.id() << "|" << id.value();
}
void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &actionID)
{
qDebug() << Q_FUNC_INFO << id << m_dbusIdMap[id];
snoreDebug( SNORE_DEBUG ) << id << m_dbusIdMap[id];
Notification noti = getActiveNotificationByID(m_dbusIdMap[id]);
if(!noti.isValid())
{
@ -113,7 +113,7 @@ void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &action
void FreedesktopBackend::slotCloseNotification ( Notification notification )
{
uint id = notification.hints().privateValue(this, "id").toUInt();
qDebug() << Q_FUNC_INFO << notification.id() << id;
snoreDebug( SNORE_DEBUG ) << notification.id() << id;
m_interface->CloseNotification(id);
}
@ -122,7 +122,7 @@ void FreedesktopBackend::slotCloseNotification ( Notification notification )
void FreedesktopBackend::slotNotificationClosed ( const uint &id,const uint &reason )
{
NotificationEnums::CloseReasons::closeReasons closeReason = NotificationEnums::CloseReasons::closeReasons(reason);
qDebug() << Q_FUNC_INFO << id << "|" << closeReason << reason;
snoreDebug( SNORE_DEBUG ) << id << "|" << closeReason << reason;
if(id == 0)
{
return;

View File

@ -58,7 +58,7 @@ bool Growl::initialize(SnoreCore *snore)
}
catch(const std::exception& e)
{
qWarning() << Q_FUNC_INFO << e.what();
qWarning() << e.what();
delete m_defaultGNTP;
m_defaultGNTP = NULL;
return false;
@ -87,11 +87,11 @@ void Growl::slotRegisterApplication(const Application &application)
gntp::gntp_callback callback(&Growl::gntpCallback);
growl->set_gntp_callback(callback);
// qDebug() << Q_FUNC_INFO << application->name().toUtf8().constData();
// snoreDebug( SNORE_DEBUG ) << application->name().toUtf8().constData();
std::vector<std::string> alerts;
foreach(const Alert &a,application.alerts())
{
// qDebug() << Q_FUNC_INFO << a->name().toUtf8().constData();
// snoreDebug( SNORE_DEBUG ) << a->name().toUtf8().constData();
alerts.push_back(a.name().toUtf8().constData());
}
@ -100,7 +100,7 @@ void Growl::slotRegisterApplication(const Application &application)
growl->regist(alerts);
}catch(const std::exception& e)
{
qWarning() << Q_FUNC_INFO << e.what();
qWarning() << e.what();
}
m_applications.insert(application.name(),growl);
}
@ -124,7 +124,7 @@ void Growl::slotNotify(Notification notification)
growl = m_defaultGNTP;
alert = "Default";
}
// qDebug() << "Notify Growl:" <<notification.application() << alert << Snore::toPlainText(notification.title());
// snoreDebug( SNORE_DEBUG ) << "Notify Growl:" <<notification.application() << alert << Snore::toPlainText(notification.title());
try
{
growl->notify(alert.toUtf8().constData(),notification.id(),
@ -135,14 +135,14 @@ void Growl::slotNotify(Notification notification)
}
catch(const std::exception& e)
{
qWarning() << Q_FUNC_INFO << e.what();
qWarning() << e.what();
}
startTimeout(notification);
}
void Growl::gntpCallback(const int &id,const std::string &reason,const std::string &data)
{
// qDebug() << Q_FUNC_INFO << id << QString(reason.c_str()) << QString(data.c_str());
// snoreDebug( SNORE_DEBUG ) << id << QString(reason.c_str()) << QString(data.c_str());
Notification n = s_instance->snore()->getActiveNotificationByID(id);
NotificationEnums::CloseReasons::closeReasons r = NotificationEnums::CloseReasons::NONE;
if(reason == "TIMEDOUT")

View File

@ -92,13 +92,13 @@ public:
break;
//away stuff
case SnarlEnums::SnarlUserAway:
qDebug()<<"Snalr user has gone away";
snoreDebug( SNORE_DEBUG )<<"Snalr user has gone away";
return true;
case SnarlEnums::SnarlUserBack:
qDebug()<<"Snalr user has returned";
snoreDebug( SNORE_DEBUG )<<"Snalr user has returned";
return true;
default:
qDebug()<<"Unknown snarl action found!!";
snoreDebug( SNORE_DEBUG )<<"Unknown snarl action found!!";
return false;
}
if(notification.isValid())
@ -108,8 +108,8 @@ public:
}
else
{
qDebug() << "Snarl notification already closed" << msg->lParam << action;
qDebug() << m_snarl->m_idMap;
snoreDebug( SNORE_DEBUG ) << "Snarl notification already closed" << msg->lParam << action;
snoreDebug( SNORE_DEBUG ) << m_snarl->m_idMap;
}
return true;
}
@ -144,7 +144,7 @@ bool SnarlBackend::initialize(SnoreCore *snore)
return false;
}
m_eventLoop = new SnarlBackend::SnarlWidget(this);
qDebug() << "Initiating Snarl Backend, Snarl version: " << snarlInterface->GetVersion();
snoreDebug( SNORE_DEBUG ) << "Initiating Snarl Backend, Snarl version: " << snarlInterface->GetVersion();
delete snarlInterface;
return SnoreBackend::initialize(snore);
}
@ -188,7 +188,7 @@ void SnarlBackend::slotDeregisterApplication(const Application &application)
{
if(!m_applications.contains(application.name()))
{
qDebug() << Q_FUNC_INFO << "Unknown apllication: " << application.name();
snoreDebug( SNORE_DEBUG ) << "Unknown apllication: " << application.name();
return;
}
SnarlInterface *snarlInterface = m_applications.take(application.name());
@ -200,7 +200,7 @@ void SnarlBackend::slotDeregisterApplication(const Application &application)
void SnarlBackend::slotNotify(Notification notification){
if(!m_applications.contains(notification.application().name()))
{
qDebug() << Q_FUNC_INFO << "Unknown apllication: " << notification.application().name();
snoreDebug( SNORE_DEBUG ) << "Unknown apllication: " << notification.application().name();
return;
}
@ -221,7 +221,7 @@ void SnarlBackend::slotNotify(Notification notification){
}
ULONG32 id = 0;
qDebug() << Q_FUNC_INFO << notification.icon();
snoreDebug( SNORE_DEBUG ) << notification.icon();
if(!notification.isUpdate())
{
id = snarlInterface->Notify(notification.alert().name().toUtf8().constData(),
@ -262,7 +262,7 @@ void SnarlBackend::slotCloseNotification(Notification notification)
{
if(!m_applications.contains(notification.application().name()))
{
qDebug() << Q_FUNC_INFO << "Unknown apllication: " << notification.application().name();
snoreDebug( SNORE_DEBUG ) << "Unknown apllication: " << notification.application().name();
return;
}
ULONG32 id = notification.hints().privateValue(this, "id").toUInt();

View File

@ -30,7 +30,7 @@ bool SnoreToast::initialize(SnoreCore *snore)
{
if(QSysInfo::windowsVersion() != QSysInfo::WV_WINDOWS8)
{
qDebug() << "SnoreToast does not work on windows" << QSysInfo::windowsVersion();
snoreDebug( SNORE_DEBUG ) << "SnoreToast does not work on windows" << QSysInfo::windowsVersion();
return false;
}
if(snore->hints().contains("WINDOWS_APP_ID"))
@ -49,10 +49,10 @@ bool SnoreToast::initialize(SnoreCore *snore)
<< QString("SnoreNotify\\%1").arg(qApp->applicationName())
<< QDir::toNativeSeparators(qApp->applicationFilePath())
<< m_appID;
qDebug() << "SnoreToast" << arguements;
snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements;
p->start("SnoreToast", arguements);
p->waitForFinished(-1);
qDebug() << p->readAll();
snoreDebug( SNORE_DEBUG ) << p->readAll();
if(p->exitCode() != 0)
{
return false;
@ -89,7 +89,7 @@ void SnoreToast::slotNotify(Notification notification)
{
arguements << "-silent";
}
qDebug() << "SnoreToast" << arguements;
snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements;
p->start("SnoreToast", arguements);
p->setProperty("SNORE_NOTIFICATION_ID",notification.id());

View File

@ -58,7 +58,7 @@ void TrayIconNotifer::slotNotify( Notification notification )
void TrayIconNotifer::slotCloseNotification(Notification n)
{
qDebug() << Q_FUNC_INFO << n;
snoreDebug( SNORE_DEBUG ) << n;
m_currentlyDisplaying = false;
displayNotification();
}

View File

@ -56,7 +56,7 @@ Parser::Parser(SnarlNetworkFrontend *snarl):
void Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* client)
{
qDebug() << Q_FUNC_INFO << msg;
snoreDebug( SNORE_DEBUG ) << msg;
QStringList splitted(msg.split("#?"));
snpTypes action(ERROR);
@ -144,7 +144,7 @@ void Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* cl
case ADD_CLASS:
if(alertName.isEmpty())
{
qDebug()<<"Error registering alert with empty name";
snoreDebug( SNORE_DEBUG )<<"Error registering alert with empty name";
break;
}
if(title.isEmpty())
@ -164,7 +164,7 @@ void Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* cl
}
else
{
qDebug() << appName << "already registred";
snoreDebug( SNORE_DEBUG ) << appName << "already registred";
}
break;
case UNREGISTER:

View File

@ -44,7 +44,7 @@ bool SnarlNetworkFrontend::initialize(SnoreCore *snore){
tcpServer = new QTcpServer(this);
if(!tcpServer->listen(QHostAddress::Any,port))
{
qDebug()<<"The port is already used";
snoreDebug( SNORE_DEBUG )<<"The port is already used";
return false;
}
else

View File

@ -46,7 +46,7 @@ SnoreNotify::SnoreNotify():
m_trayIcon->initConextMenu(m_snore);
connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(exit()));
qDebug() << "Snorenotfiy initialized with" << m_snore->primaryNotificationBackend();
snoreDebug( SNORE_DEBUG ) << "Snorenotfiy initialized with" << m_snore->primaryNotificationBackend();
}
SnoreNotify::~SnoreNotify(){
@ -69,7 +69,7 @@ void SnoreNotify::save(){
}
void SnoreNotify::exit(){
qDebug()<<"Saving snore settings";
snoreDebug( SNORE_DEBUG )<<"Saving snore settings";
foreach(const Application &a,m_snore->aplications())
{
m_snore->deregisterApplication(a);