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
- Use default domain values if no domain-specific values exist
......
Name: ssu
Version: 0.19
Version: 0.20
Release: 1
Summary: SSU enabler for RND
Group: System/Base
......@@ -10,6 +10,7 @@ BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(libzypp)
BuildRequires: pkgconfig(QtSystemInfo)
BuildRequires: pkgconfig(qt-boostable)
BuildRequires: pkgconfig(libsystemd-journal)
Requires(pre): shadow-utils
Requires(postun): shadow-utils
Requires: ssu-vendor-data
......
......@@ -6,17 +6,31 @@
*/
#include <QCoreApplication>
#include <systemd/sd-journal.h>
#include "ssuurlresolver.h"
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()),
QCoreApplication::instance(),SLOT(quit()),
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(){
QHash<QString, QString> repoParameters;
QString resolvedUrl, repo;
......@@ -26,7 +40,7 @@ void SsuUrlResolver::run(){
if (in.headerEmpty()){
// 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;
......@@ -72,7 +86,7 @@ void SsuUrlResolver::run(){
// TODO: check for credentials scope required for repository; check if the file exists;
// 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);
if (!credentialsScope.isEmpty()){
headerList.append(QString("credentials=%1").arg(credentialsScope));
......@@ -100,7 +114,8 @@ void SsuUrlResolver::run(){
.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");
out.setBody(resolvedUrl.toStdString());
out.writeTo(std::cout);
......
......@@ -52,8 +52,7 @@ class SsuUrlResolver: public QObject {
private:
Ssu ssu;
QFile logfile;
QTextStream logstream;
void printJournal(int priority, QString message);
public slots:
void run();
......
......@@ -8,7 +8,7 @@ CONFIG -= app_bundle
CONFIG += console link_pkgconfig
QT -= gui
QT += network
PKGCONFIG += libzypp
PKGCONFIG += libzypp libsystemd-journal
unix:target.path = $${PREFIX}/usr/lib/zypp/plugins/urlresolver
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