59 m_pInstance->context = NULL;
60 m_pInstance->publisher = NULL;
61 m_pInstance->connection =
"";
67 m_pInstance->enabled =
false;
72 ResvgRenderer::initLog();
83 const juce::GenericScopedLock<juce::CriticalSection> lock(loggerCriticalSection);
86 if (new_connection == connection)
90 connection = new_connection;
92 if (context == NULL) {
94 context =
new zmq::context_t(1);
97 if (publisher != NULL) {
104 publisher =
new zmq::socket_t(*context, ZMQ_PUB);
108 publisher->bind(connection.c_str());
110 }
catch (zmq::error_t &e) {
111 std::cout <<
"ZmqLogger::Connection - Error binding to " << connection <<
". Switching to an available port." << std::endl;
112 connection =
"tcp://*:*";
113 publisher->bind(connection.c_str());
117 std::this_thread::sleep_for(std::chrono::milliseconds(250));
127 const juce::GenericScopedLock<juce::CriticalSection> lock(loggerCriticalSection);
130 zmq::message_t reply (message.length());
131 std::memcpy (reply.data(), message.c_str(), message.length());
133 #if ZMQ_VERSION > ZMQ_MAKE_VERSION(4, 3, 1)
135 publisher->send(reply, zmq::send_flags::dontwait);
137 publisher->send(reply);
148 if (log_file.is_open())
149 log_file << message << std::flush;
155 file_path = new_path;
158 if (log_file.is_open())
162 log_file.open (file_path.c_str(), std::ios::out | std::ios::app);
165 std::time_t now = std::time(0);
166 std::tm* localtm = std::localtime(&now);
167 log_file <<
"------------------------------------------" << std::endl;
168 log_file <<
"libopenshot logging: " << std::asctime(localtm);
169 log_file <<
"------------------------------------------" << std::endl;
178 if (log_file.is_open())
182 if (publisher != NULL) {
191 std::string arg1_name,
float arg1_value,
192 std::string arg2_name,
float arg2_value,
193 std::string arg3_name,
float arg3_value,
194 std::string arg4_name,
float arg4_value,
195 std::string arg5_name,
float arg5_value,
196 std::string arg6_name,
float arg6_value)
204 const juce::GenericScopedLock<juce::CriticalSection> lock(loggerCriticalSection);
206 std::stringstream message;
207 message << std::fixed << std::setprecision(4);
210 message << method_name <<
" (";
212 if (arg1_name.length() > 0)
213 message << arg1_name <<
"=" << arg1_value;
215 if (arg2_name.length() > 0)
216 message <<
", " << arg2_name <<
"=" << arg2_value;
218 if (arg3_name.length() > 0)
219 message <<
", " << arg3_name <<
"=" << arg3_value;
221 if (arg4_name.length() > 0)
222 message <<
", " << arg4_name <<
"=" << arg4_value;
224 if (arg5_name.length() > 0)
225 message <<
", " << arg5_name <<
"=" << arg5_value;
227 if (arg6_name.length() > 0)
228 message <<
", " << arg6_name <<
"=" << arg6_value;
230 message <<
")" << std::endl;
234 std::clog << message.str();
Header file for all Exception classes.
Header file for ZeroMQ-based Logger class.
static Settings * Instance()
Create or get an instance of this logger singleton (invoke the class with this method)
This class is used for logging and sending those logs over a ZemoMQ socket to a listener.
void Close()
Close logger (sockets and/or files)
void Log(std::string message)
Log message to all subscribers of this logger (if any)
void Path(std::string new_path)
Set or change the file path (optional)
void LogToFile(std::string message)
Log message to a file (if path set)
void Connection(std::string new_connection)
Set or change connection info for logger (i.e. tcp://*:5556)
void AppendDebugMethod(std::string method_name, std::string arg1_name="", float arg1_value=-1.0, std::string arg2_name="", float arg2_value=-1.0, std::string arg3_name="", float arg3_value=-1.0, std::string arg4_name="", float arg4_value=-1.0, std::string arg5_name="", float arg5_value=-1.0, std::string arg6_name="", float arg6_value=-1.0)
Append debug information.
static ZmqLogger * Instance()
Create or get an instance of this logger singleton (invoke the class with this method)
This namespace is the default namespace for all code in the openshot library.