logging rework json/proto (#102)

* cleanup: remove ambiled device

as written at the forum this is no longer supported. All people should move to adalight. They just need to flash a new sketch.

* fix typo

* travis.ci

* travis: move to ubuntu 14.04

* script try

* add serialport

* update .json files

* .

* .

* .

* update travis

* fix

* typo

* fix

* .

* disable v4l2 on mac

* disable email notification

* update osx

* maybe fix

* .

* disable osx and rm v4l2

* try osx

* try fix

* travis update

* add oe systemd file

* Proto

* Json

* fix

* fix2

* fix3

* .

* typo

* update

* revert runtime error
This commit is contained in:
brindosch
2016-07-11 17:08:22 +02:00
committed by GitHub
parent 070a534262
commit c802505553
11 changed files with 44 additions and 29 deletions

View File

@@ -10,8 +10,9 @@
ProtoConnection::ProtoConnection(const std::string & a) :
_socket(),
_skipReply(false),
_prevSocketState(QAbstractSocket::UnconnectedState)
{
_prevSocketState(QAbstractSocket::UnconnectedState),
_log(Logger::getInstance("PROTOCONNECTION"))
{
QString address(a.c_str());
QStringList parts = address.split(":");
if (parts.size() != 2)
@@ -28,7 +29,7 @@ ProtoConnection::ProtoConnection(const std::string & a) :
}
// try to connect to host
std::cout << "PROTOCONNECTION INFO: Connecting to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
Info(_log, "Connecting to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
connectToHost();
// start the connection timer
@@ -74,7 +75,7 @@ void ProtoConnection::readData()
if (!reply.ParseFromArray(_receiveBuffer.data() + 4, messageSize))
{
std::cerr << "PROTOCONNECTION ERROR: Unable to parse message" << std::endl;
Error(_log, "Unable to parse message");
return;
}
@@ -155,11 +156,11 @@ void ProtoConnection::sendMessage(const proto::HyperionRequest &message)
switch (_socket.state() )
{
case QAbstractSocket::UnconnectedState:
std::cout << "PROTOCONNECTION INFO: No connection to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
Info(_log, "No connection to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
break;
case QAbstractSocket::ConnectedState:
std::cout << "PROTOCONNECTION INFO: Connected to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
Info(_log, "Connected to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
break;
default:
@@ -193,7 +194,7 @@ void ProtoConnection::sendMessage(const proto::HyperionRequest &message)
count += _socket.write(reinterpret_cast<const char *>(serializedMessage.data()), length);
if (!_socket.waitForBytesWritten())
{
std::cerr << "PROTOCONNECTION ERROR: Error while writing data to host" << std::endl;
Error(_log, "Error while writing data to host");
return;
}
}

View File

@@ -11,7 +11,8 @@ ProtoServer::ProtoServer(uint16_t port) :
QObject(),
_hyperion(Hyperion::getInstance()),
_server(),
_openConnections()
_openConnections(),
_log(Logger::getInstance("PROTOSERVER"))
{
MessageForwarder * forwarder = _hyperion->getForwarder();
@@ -57,7 +58,7 @@ void ProtoServer::newConnection()
if (socket != nullptr)
{
std::cout << "PROTOSERVER INFO: New connection" << std::endl;
Debug(_log, "New connection");
ProtoClientConnection * connection = new ProtoClientConnection(socket, _hyperion);
_openConnections.insert(connection);
@@ -86,7 +87,7 @@ void ProtoServer::sendImageToProtoSlaves(int priority, const Image<ColorRgb> & i
void ProtoServer::closedConnection(ProtoClientConnection *connection)
{
std::cout << "PROTOSERVER INFO: Connection closed" << std::endl;
Debug(_log, "Connection closed");
_openConnections.remove(connection);
// schedule to delete the connection object