Loading...
Searching...
No Matches
ZmqLogger.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_LOGGER_H
#define OPENSHOT_LOGGER_H
#include <fstream>
#include <memory>
#include <mutex>
#include <string>
#include <zmq.hpp>
namespace openshot {
class ZmqLogger {
private:
std::recursive_mutex loggerMutex;
std::string connection;
// Logfile related vars
std::string file_path;
std::ofstream log_file;
bool enabled;
zmq::context_t *context;
zmq::socket_t *publisher;
ZmqLogger(){}; // Don't allow user to create an instance of this singleton
#if __GNUC__ >=7
ZmqLogger(ZmqLogger const&) = delete; // Don't allow the user to assign this instance
ZmqLogger & operator=(ZmqLogger const&) = delete; // Don't allow the user to assign this instance
#else
ZmqLogger(ZmqLogger const&) {}; // Don't allow the user to assign this instance
ZmqLogger & operator=(ZmqLogger const&); // Don't allow the user to assign this instance
#endif
static ZmqLogger * m_pInstance;
public:
static ZmqLogger * Instance();
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
);
void Close();
void Connection(std::string new_connection);
void Enable(bool is_enabled) { enabled = is_enabled;};
void Path(std::string new_path);
void Log(std::string message);
void LogToFile(std::string message);
};
}
#endif
openshot::ZmqLogger::Close
void Close()
Close logger (sockets and/or files).
Definition ZmqLogger.cpp:155
openshot::ZmqLogger::Enable
void Enable(bool is_enabled)
Enable/Disable logging.
Definition ZmqLogger.h:90
openshot::ZmqLogger::Log
void Log(std::string message)
Log message to all subscribers of this logger (if any).
Definition ZmqLogger.cpp:103
openshot::ZmqLogger::Path
void Path(std::string new_path)
Set or change the file path (optional).
Definition ZmqLogger.cpp:135
openshot::ZmqLogger::LogToFile
void LogToFile(std::string message)
Log message to a file (if path set).
Definition ZmqLogger.cpp:128
openshot::ZmqLogger::Connection
void Connection(std::string new_connection)
Set or change connection info for logger (i.e. tcp://*:5556).
Definition ZmqLogger.cpp:63
openshot::ZmqLogger::AppendDebugMethod
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.
Definition ZmqLogger.cpp:178
openshot::ZmqLogger::Instance
static ZmqLogger * Instance()
Create or get an instance of this logger singleton (invoke the class with this method).
Definition ZmqLogger.cpp:35
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29