Logging migration continues ... (#97)

* migrate logging for blackborder and bonjour. fix logging bug in hyperion

* fix kodichecker when kodi is not there
This commit is contained in:
redPanther 2016-07-10 23:14:23 +02:00 committed by brindosch
parent 3ac0781c1f
commit c2e2c26ab2
7 changed files with 76 additions and 67 deletions

View File

@ -3,6 +3,7 @@
// Jsoncpp includes // Jsoncpp includes
#include <json/json.h> #include <json/json.h>
// Local Hyperion includes // Local Hyperion includes
#include "BlackBorderDetector.h" #include "BlackBorderDetector.h"
@ -107,6 +108,5 @@ namespace hyperion
unsigned _consistentCnt; unsigned _consistentCnt;
/// The number of frame the previous detected border NOT matched the incomming border /// The number of frame the previous detected border NOT matched the incomming border
unsigned _inconsistentCnt; unsigned _inconsistentCnt;
}; };
} // end namespace hyperion } // end namespace hyperion

View File

@ -1,12 +1,14 @@
#include <iostream> #include <iostream>
#include <utils/Logger.h>
// BlackBorders includes // BlackBorders includes
#include <blackborder/BlackBorderDetector.h> #include <blackborder/BlackBorderDetector.h>
#include <cmath> #include <cmath>
using namespace hyperion; using namespace hyperion;
BlackBorderDetector::BlackBorderDetector(double threshold) : BlackBorderDetector::BlackBorderDetector(double threshold)
_blackborderThreshold(calculateThreshold(threshold)) : _blackborderThreshold(calculateThreshold(threshold))
{ {
// empty // empty
} }
@ -21,7 +23,7 @@ uint8_t BlackBorderDetector::calculateThreshold(double threshold)
uint8_t blackborderThreshold = uint8_t(rgbThreshold); uint8_t blackborderThreshold = uint8_t(rgbThreshold);
std::cout << "BLACKBORDER INFO: threshold set to " << threshold << " (" << int(blackborderThreshold) << ")" << std::endl; Info(Logger::getInstance("BLACKBORDER"), "threshold set to %f (%d)", threshold , int(blackborderThreshold));
return blackborderThreshold; return blackborderThreshold;
} }

View File

@ -1,8 +1,6 @@
#include <iostream> #include <iostream>
/*
#include <iomanip> #include <utils/Logger.h>
using std::setw;
//*/
// Blackborder includes // Blackborder includes
#include <blackborder/BlackBorderProcessor.h> #include <blackborder/BlackBorderProcessor.h>
@ -10,20 +8,19 @@ using std::setw;
using namespace hyperion; using namespace hyperion;
BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig) : BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig)
_unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt()), : _unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt())
_borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt()), , _borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt())
_maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt()), , _maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt())
_blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt()), , _blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt())
_detectionMode(blackborderConfig.get("mode", "default").asString()), , _detectionMode(blackborderConfig.get("mode", "default").asString())
_detector(blackborderConfig.get("threshold", 0.01).asDouble()), , _detector(blackborderConfig.get("threshold", 0.01).asDouble())
_currentBorder({true, -1, -1}), , _currentBorder({true, -1, -1})
_previousDetectedBorder({true, -1, -1}), , _previousDetectedBorder({true, -1, -1})
_consistentCnt(0), , _consistentCnt(0)
_inconsistentCnt(10) , _inconsistentCnt(10)
{ {
std::cout << "BLACKBORDER INFO: mode:" << _detectionMode << std::endl; Info(Logger::getInstance("BLACKBORDER"), "mode: %s", _detectionMode.c_str());
// empty
} }
BlackBorder BlackBorderProcessor::getCurrentBorder() const BlackBorder BlackBorderProcessor::getCurrentBorder() const

View File

@ -31,6 +31,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QtCore/QSocketNotifier> #include <QtCore/QSocketNotifier>
#include <utils/Logger.h>
BonjourServiceRegister::BonjourServiceRegister(QObject *parent) BonjourServiceRegister::BonjourServiceRegister(QObject *parent)
: QObject(parent), dnssref(0), bonjourSocket(0) : QObject(parent), dnssref(0), bonjourSocket(0)
{ {
@ -39,49 +41,56 @@ BonjourServiceRegister::BonjourServiceRegister(QObject *parent)
BonjourServiceRegister::~BonjourServiceRegister() BonjourServiceRegister::~BonjourServiceRegister()
{ {
if (dnssref) { if (dnssref)
DNSServiceRefDeallocate(dnssref); {
dnssref = 0; DNSServiceRefDeallocate(dnssref);
} dnssref = 0;
}
} }
void BonjourServiceRegister::registerService(const BonjourRecord &record, quint16 servicePort) void BonjourServiceRegister::registerService(const BonjourRecord &record, quint16 servicePort)
{ {
if (dnssref) { if (dnssref)
qWarning("Warning: Already registered a service for this object, aborting new register"); {
return; Warning(Logger::getInstance("BonJour"), "Already registered a service for this object, aborting new register");
} return;
quint16 bigEndianPort = servicePort; }
quint16 bigEndianPort = servicePort;
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
{ {
bigEndianPort = 0 | ((servicePort & 0x00ff) << 8) | ((servicePort & 0xff00) >> 8); bigEndianPort = 0 | ((servicePort & 0x00ff) << 8) | ((servicePort & 0xff00) >> 8);
} }
#endif #endif
DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(), DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(),
record.registeredType.toUtf8().constData(), record.registeredType.toUtf8().constData(),
record.replyDomain.isEmpty() ? 0 (record.replyDomain.isEmpty() ? 0 : record.replyDomain.toUtf8().constData()),
: record.replyDomain.toUtf8().constData(), 0, 0, bigEndianPort, 0, 0, bonjourRegisterService, this);
bigEndianPort, 0, 0, bonjourRegisterService, this); if (err != kDNSServiceErr_NoError)
if (err != kDNSServiceErr_NoError) { {
emit error(err); emit error(err);
} else { }
int sockfd = DNSServiceRefSockFD(dnssref); else
if (sockfd == -1) { {
emit error(kDNSServiceErr_Invalid); int sockfd = DNSServiceRefSockFD(dnssref);
} else { if (sockfd == -1)
bonjourSocket = new QSocketNotifier(sockfd, QSocketNotifier::Read, this); {
connect(bonjourSocket, SIGNAL(activated(int)), this, SLOT(bonjourSocketReadyRead())); emit error(kDNSServiceErr_Invalid);
} }
} else
{
bonjourSocket = new QSocketNotifier(sockfd, QSocketNotifier::Read, this);
connect(bonjourSocket, SIGNAL(activated(int)), this, SLOT(bonjourSocketReadyRead()));
}
}
} }
void BonjourServiceRegister::bonjourSocketReadyRead() void BonjourServiceRegister::bonjourSocketReadyRead()
{ {
DNSServiceErrorType err = DNSServiceProcessResult(dnssref); DNSServiceErrorType err = DNSServiceProcessResult(dnssref);
if (err != kDNSServiceErr_NoError) if (err != kDNSServiceErr_NoError)
emit error(err); emit error(err);
} }
@ -90,13 +99,16 @@ void BonjourServiceRegister::bonjourRegisterService(DNSServiceRef, DNSServiceFla
const char *regtype, const char *domain, const char *regtype, const char *domain,
void *data) void *data)
{ {
BonjourServiceRegister *serviceRegister = static_cast<BonjourServiceRegister *>(data); BonjourServiceRegister *serviceRegister = static_cast<BonjourServiceRegister *>(data);
if (errorCode != kDNSServiceErr_NoError) { if (errorCode != kDNSServiceErr_NoError)
emit serviceRegister->error(errorCode); {
} else { emit serviceRegister->error(errorCode);
serviceRegister->finalRecord = BonjourRecord(QString::fromUtf8(name), }
QString::fromUtf8(regtype), else
QString::fromUtf8(domain)); {
emit serviceRegister->serviceRegistered(serviceRegister->finalRecord); serviceRegister->finalRecord = BonjourRecord(QString::fromUtf8(name),
} QString::fromUtf8(regtype),
QString::fromUtf8(domain));
emit serviceRegister->serviceRegistered(serviceRegister->finalRecord);
}
} }

View File

@ -138,8 +138,6 @@ bool EffectEngine::loadEffectDefinition(const std::string &path, const std::stri
effectDefinition.script = path + QDir::separator().toLatin1() + config["script"].asString(); effectDefinition.script = path + QDir::separator().toLatin1() + config["script"].asString();
effectDefinition.args = config["args"]; effectDefinition.args = config["args"];
// return succes //BLACKLIST OUTPUT TO LOG (Spam). This is more a effect development thing and the list gets longer and longer
// std::cout << "EFFECTENGINE INFO: Effect loaded: " + effectDefinition.name << std::endl;
return true; return true;
} }

View File

@ -202,7 +202,7 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt,
for (int i=0; i<ledIndexList.size(); ++i) { for (int i=0; i<ledIndexList.size(); ++i) {
if (i > 0) if (i > 0)
{ {
std::cout << ", "; ss << ", ";
} }
if (ledIndexList[i].contains("-")) if (ledIndexList[i].contains("-"))
{ {
@ -211,13 +211,13 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt,
int endInd = ledIndices[1].toInt(); int endInd = ledIndices[1].toInt();
transform->setTransformForLed(colorTransform->_id, startInd, endInd); transform->setTransformForLed(colorTransform->_id, startInd, endInd);
std::cout << startInd << "-" << endInd; ss << startInd << "-" << endInd;
} }
else else
{ {
int index = ledIndexList[i].toInt(); int index = ledIndexList[i].toInt();
transform->setTransformForLed(colorTransform->_id, index, index); transform->setTransformForLed(colorTransform->_id, index, index);
std::cout << index; ss << index;
} }
} }
Info(log, "ColorTransform '%s' => [%s]", colorTransform->_id.c_str(), ss.str().c_str()); Info(log, "ColorTransform '%s' => [%s]", colorTransform->_id.c_str(), ss.str().c_str());

View File

@ -310,7 +310,7 @@ void KODIVideoChecker::reconnect()
void KODIVideoChecker::connectionError(QAbstractSocket::SocketError error) void KODIVideoChecker::connectionError(QAbstractSocket::SocketError error)
{ {
Error(_log,"Connection error (%s)", error); Error(_log,"Connection error (%s)", _socket.errorString().toStdString().c_str());
// close the socket // close the socket
_socket.close(); _socket.close();