Commit b062d35c authored by Aard's avatar Aard

[ssu] Only log ERR or higher, add loglevel setting in ssu.ini

parent 499014fa
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <QTextStream> #include <QTextStream>
#include "ssulog.h" #include "ssulog.h"
#include "ssucoreconfig.h"
SsuLog *SsuLog::ssuLog = 0; SsuLog *SsuLog::ssuLog = 0;
...@@ -16,6 +17,7 @@ SsuLog *SsuLog::instance(){ ...@@ -16,6 +17,7 @@ SsuLog *SsuLog::instance(){
if (!ssuLog){ if (!ssuLog){
ssuLog = new SsuLog(); ssuLog = new SsuLog();
ssuLog->fallbackLogPath = "/tmp/ssu.log"; ssuLog->fallbackLogPath = "/tmp/ssu.log";
ssuLog->ssuLogLevel = -1;
} }
return ssuLog; return ssuLog;
...@@ -25,6 +27,20 @@ void SsuLog::print(int priority, QString message){ ...@@ -25,6 +27,20 @@ void SsuLog::print(int priority, QString message){
QByteArray ba = message.toUtf8(); QByteArray ba = message.toUtf8();
const char *ca = ba.constData(); const char *ca = ba.constData();
if (ssuLogLevel == -1){
SsuCoreConfig *settings = SsuCoreConfig::instance();
if (settings->contains("loglevel"))
ssuLog->ssuLogLevel = settings->value("loglevel").toInt();
else
ssuLog->ssuLogLevel = LOG_ERR;
}
// this is rather dirty, but since systemd does not seem to allow to enable debug
// logging only for specific services probably best way for now
if (priority > ssuLogLevel)
return;
if (sd_journal_print(priority, "ssu: %s", ca) < 0 && fallbackLogPath != ""){ if (sd_journal_print(priority, "ssu: %s", ca) < 0 && fallbackLogPath != ""){
QFile logfile; QFile logfile;
QTextStream logstream; QTextStream logstream;
......
...@@ -26,6 +26,7 @@ class SsuLog { ...@@ -26,6 +26,7 @@ class SsuLog {
SsuLog(const SsuLog &); // hide copy constructor SsuLog(const SsuLog &); // hide copy constructor
static SsuLog *ssuLog; static SsuLog *ssuLog;
int ssuLogLevel;
QString fallbackLogPath; QString fallbackLogPath;
}; };
......
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