42 m_pInstance->context = NULL;
43 m_pInstance->publisher = NULL;
44 m_pInstance->connection =
"";
50 m_pInstance->enabled =
false;
55 ResvgRenderer::initLog();
66 const std::lock_guard<std::recursive_mutex> lock(loggerMutex);
69 if (new_connection == connection)
73 connection = new_connection;
75 if (context == NULL) {
77 context =
new zmq::context_t(1);
80 if (publisher != NULL) {
87 publisher =
new zmq::socket_t(*context, ZMQ_PUB);
91 publisher->bind(connection.c_str());
93 }
catch (zmq::error_t &e) {
94 std::cout <<
"ZmqLogger::Connection - Error binding to " << connection <<
". Switching to an available port." << std::endl;
95 connection =
"tcp://*:*";
96 publisher->bind(connection.c_str());
100 std::this_thread::sleep_for(std::chrono::milliseconds(250));
110 const std::lock_guard<std::recursive_mutex> lock(loggerMutex);
113 zmq::message_t reply (message.length());
114 std::memcpy (reply.data(), message.c_str(), message.length());
116 #if ZMQ_VERSION > ZMQ_MAKE_VERSION(4, 3, 1)
118 publisher->send(reply, zmq::send_flags::dontwait);
120 publisher->send(reply);
131 if (log_file.is_open())
132 log_file << message << std::flush;
138 file_path = new_path;
141 if (log_file.is_open())
145 log_file.open (file_path.c_str(), std::ios::out | std::ios::app);
148 std::time_t now = std::time(0);
149 std::tm* localtm = std::localtime(&now);
150 log_file <<
"------------------------------------------" << std::endl;
151 log_file <<
"libopenshot logging: " << std::asctime(localtm);
152 log_file <<
"------------------------------------------" << std::endl;
161 if (log_file.is_open())
165 if (publisher != NULL) {
172 if (context != NULL) {
179 std::string arg1_name,
float arg1_value,
180 std::string arg2_name,
float arg2_value,
181 std::string arg3_name,
float arg3_value,
182 std::string arg4_name,
float arg4_value,
183 std::string arg5_name,
float arg5_value,
184 std::string arg6_name,
float arg6_value)
192 const std::lock_guard<std::recursive_mutex> lock(loggerMutex);
194 std::stringstream message;
195 message << std::fixed << std::setprecision(4);
198 message << method_name <<
" (";
200 if (arg1_name.length() > 0)
201 message << arg1_name <<
"=" << arg1_value;
203 if (arg2_name.length() > 0)
204 message <<
", " << arg2_name <<
"=" << arg2_value;
206 if (arg3_name.length() > 0)
207 message <<
", " << arg3_name <<
"=" << arg3_value;
209 if (arg4_name.length() > 0)
210 message <<
", " << arg4_name <<
"=" << arg4_value;
212 if (arg5_name.length() > 0)
213 message <<
", " << arg5_name <<
"=" << arg5_value;
215 if (arg6_name.length() > 0)
216 message <<
", " << arg6_name <<
"=" << arg6_value;
218 message <<
")" << std::endl;
222 std::clog << message.str();