Commit f67e76a1 authored by Aard's avatar Aard

Make url resolver log to systemd journal, and use /tmp/ssu.log as fallback

parent 649f47c2
* Tue Jan 29 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.20
- Move ssu resolver log to systemd journal, with fallback in /tmp/ssu.log
* Tue Jan 29 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.19 * Tue Jan 29 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.19
- Use default domain values if no domain-specific values exist - Use default domain values if no domain-specific values exist
......
Name: ssu Name: ssu
Version: 0.19 Version: 0.20
Release: 1 Release: 1
Summary: SSU enabler for RND Summary: SSU enabler for RND
Group: System/Base Group: System/Base
...@@ -10,6 +10,7 @@ BuildRequires: pkgconfig(QtCore) ...@@ -10,6 +10,7 @@ BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(libzypp) BuildRequires: pkgconfig(libzypp)
BuildRequires: pkgconfig(QtSystemInfo) BuildRequires: pkgconfig(QtSystemInfo)
BuildRequires: pkgconfig(qt-boostable) BuildRequires: pkgconfig(qt-boostable)
BuildRequires: pkgconfig(libsystemd-journal)
Requires(pre): shadow-utils Requires(pre): shadow-utils
Requires(postun): shadow-utils Requires(postun): shadow-utils
Requires: ssu-vendor-data Requires: ssu-vendor-data
......
...@@ -6,17 +6,31 @@ ...@@ -6,17 +6,31 @@
*/ */
#include <QCoreApplication> #include <QCoreApplication>
#include <systemd/sd-journal.h>
#include "ssuurlresolver.h" #include "ssuurlresolver.h"
SsuUrlResolver::SsuUrlResolver(): QObject(){ SsuUrlResolver::SsuUrlResolver(): QObject(){
logfile.setFileName("/var/log/ssu.log");
logfile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
logstream.setDevice(&logfile);
QObject::connect(this,SIGNAL(done()), QObject::connect(this,SIGNAL(done()),
QCoreApplication::instance(),SLOT(quit()), QCoreApplication::instance(),SLOT(quit()),
Qt::QueuedConnection); Qt::QueuedConnection);
} }
void SsuUrlResolver::printJournal(int priority, QString message){
QByteArray ba = message.toUtf8();
const char *ca = ba.constData();
if (sd_journal_print(LOG_INFO, "ssu: %s", ca) < 0){
QFile logfile;
QTextStream logstream;
logfile.setFileName("/tmp/ssu.log");
logfile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
logstream.setDevice(&logfile);
logstream << message << "\n";
logstream.flush();
}
}
void SsuUrlResolver::run(){ void SsuUrlResolver::run(){
QHash<QString, QString> repoParameters; QHash<QString, QString> repoParameters;
QString resolvedUrl, repo; QString resolvedUrl, repo;
...@@ -26,7 +40,7 @@ void SsuUrlResolver::run(){ ...@@ -26,7 +40,7 @@ void SsuUrlResolver::run(){
if (in.headerEmpty()){ if (in.headerEmpty()){
// FIXME, do something; we need at least repo header // FIXME, do something; we need at least repo header
logstream << "D'oh, received empty header list\n"; printJournal(LOG_WARNING, "Received empty header list. Most likely your ssu setup is broken");
} }
PluginFrame::HeaderListIterator it; PluginFrame::HeaderListIterator it;
...@@ -72,7 +86,7 @@ void SsuUrlResolver::run(){ ...@@ -72,7 +86,7 @@ void SsuUrlResolver::run(){
// TODO: check for credentials scope required for repository; check if the file exists; // TODO: check for credentials scope required for repository; check if the file exists;
// compare with configuration, and dump credentials to file if necessary // compare with configuration, and dump credentials to file if necessary
logstream << QString("Requesting credentials for '%1' with RND status %2...").arg(repo).arg(isRnd); printJournal(LOG_DEBUG, QString("Requesting credentials for '%1' with RND status %2...").arg(repo).arg(isRnd));
QString credentialsScope = ssu.credentialsScope(repo, isRnd); QString credentialsScope = ssu.credentialsScope(repo, isRnd);
if (!credentialsScope.isEmpty()){ if (!credentialsScope.isEmpty()){
headerList.append(QString("credentials=%1").arg(credentialsScope)); headerList.append(QString("credentials=%1").arg(credentialsScope));
...@@ -100,7 +114,8 @@ void SsuUrlResolver::run(){ ...@@ -100,7 +114,8 @@ void SsuUrlResolver::run(){
.arg(headerList.join("&")); .arg(headerList.join("&"));
} }
logstream << QString("resolved to %1\n").arg(resolvedUrl); printJournal(LOG_INFO, QString("%1 resolved to %2").arg(repo).arg(resolvedUrl));
PluginFrame out("RESOLVEDURL"); PluginFrame out("RESOLVEDURL");
out.setBody(resolvedUrl.toStdString()); out.setBody(resolvedUrl.toStdString());
out.writeTo(std::cout); out.writeTo(std::cout);
......
...@@ -52,8 +52,7 @@ class SsuUrlResolver: public QObject { ...@@ -52,8 +52,7 @@ class SsuUrlResolver: public QObject {
private: private:
Ssu ssu; Ssu ssu;
QFile logfile; void printJournal(int priority, QString message);
QTextStream logstream;
public slots: public slots:
void run(); void run();
......
...@@ -8,7 +8,7 @@ CONFIG -= app_bundle ...@@ -8,7 +8,7 @@ CONFIG -= app_bundle
CONFIG += console link_pkgconfig CONFIG += console link_pkgconfig
QT -= gui QT -= gui
QT += network QT += network
PKGCONFIG += libzypp PKGCONFIG += libzypp libsystemd-journal
unix:target.path = $${PREFIX}/usr/lib/zypp/plugins/urlresolver unix:target.path = $${PREFIX}/usr/lib/zypp/plugins/urlresolver
INSTALLS += target INSTALLS += target
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment