28 #include "../include/ZmqLogger.h"
31 using namespace openshot;
45 m_pInstance->context = NULL;
46 m_pInstance->publisher = NULL;
47 m_pInstance->connection =
"";
50 m_pInstance->Connection(
"tcp://*:5556");
57 void ZmqLogger::Connection(
string new_connection)
60 const GenericScopedLock<CriticalSection> lock(loggerCriticalSection);
63 if (new_connection == connection)
67 connection = new_connection;
69 if (context == NULL) {
71 context =
new zmq::context_t(1);
74 if (publisher != NULL) {
81 publisher =
new zmq::socket_t(*context, ZMQ_PUB);
85 publisher->bind(connection.c_str());
87 }
catch (zmq::error_t &
e) {
88 cout <<
"ZmqLogger::Connection - Error binding to " << connection <<
". Switching to an available port." << endl;
89 connection =
"tcp://*:*";
90 publisher->bind(connection.c_str());
97 void ZmqLogger::Log(
string message)
100 const GenericScopedLock<CriticalSection> lock(loggerCriticalSection);
103 zmq::message_t reply (message.length());
104 memcpy (reply.data(), message.c_str(), message.length());
105 publisher->send(reply);
This abstract class is the base class, used by all readers in libopenshot.