mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
base: Improve logging
This commit is contained in:
parent
e2d837958f
commit
b53b40d9c8
@ -45,29 +45,29 @@ WebSocketServer::~WebSocketServer()
|
||||
|
||||
void WebSocketServer::ServerRunner()
|
||||
{
|
||||
blog(LOG_INFO, "IO thread started.");
|
||||
blog(LOG_INFO, "[ServerRunner] IO thread started.");
|
||||
try {
|
||||
_server.run();
|
||||
} catch (websocketpp::exception const & e) {
|
||||
blog(LOG_ERROR, "websocketpp instance returned an error: %s", e.what());
|
||||
blog(LOG_ERROR, "[ServerRunner] websocketpp instance returned an error: %s", e.what());
|
||||
} catch (const std::exception & e) {
|
||||
blog(LOG_ERROR, "websocketpp instance returned an error: %s", e.what());
|
||||
blog(LOG_ERROR, "[ServerRunner] websocketpp instance returned an error: %s", e.what());
|
||||
} catch (...) {
|
||||
blog(LOG_ERROR, "websocketpp instance returned an error");
|
||||
blog(LOG_ERROR, "[ServerRunner] websocketpp instance returned an error");
|
||||
}
|
||||
blog(LOG_INFO, "IO thread exited.");
|
||||
blog(LOG_INFO, "[ServerRunner] IO thread exited.");
|
||||
}
|
||||
|
||||
void WebSocketServer::Start()
|
||||
{
|
||||
if (_server.is_listening()) {
|
||||
blog(LOG_WARNING, "Call to Start() but the server is already listening.");
|
||||
blog(LOG_WARNING, "[Start] Call to Start() but the server is already listening.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto conf = GetConfig();
|
||||
if (!conf) {
|
||||
blog(LOG_ERROR, "Unable to retreive config!");
|
||||
blog(LOG_ERROR, "[Start] Unable to retreive config!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ void WebSocketServer::Start()
|
||||
|
||||
if (errorCode) {
|
||||
std::string errorCodeMessage = errorCode.message();
|
||||
blog(LOG_INFO, "Listen failed: %s", errorCodeMessage.c_str());
|
||||
blog(LOG_INFO, "[Start] Listen failed: %s", errorCodeMessage.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,12 +90,13 @@ void WebSocketServer::Start()
|
||||
|
||||
_serverThread = std::thread(&WebSocketServer::ServerRunner, this);
|
||||
|
||||
blog(LOG_INFO, "Server started successfully on port %d", _serverPort);
|
||||
blog(LOG_INFO, "[Start] Server started successfully on port %d", _serverPort);
|
||||
}
|
||||
|
||||
void WebSocketServer::Stop()
|
||||
{
|
||||
if (!_server.is_listening()) {
|
||||
blog(LOG_WARNING, "[Stop] Call to Stop() but the server is not listening.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,12 +119,12 @@ void WebSocketServer::Stop()
|
||||
|
||||
_serverThread.join();
|
||||
|
||||
blog(LOG_INFO, "Server stopped successfully");
|
||||
blog(LOG_INFO, "[Stop] Server stopped successfully");
|
||||
}
|
||||
|
||||
void WebSocketServer::InvalidateSession(websocketpp::connection_hdl hdl)
|
||||
{
|
||||
blog(LOG_INFO, "Invalidating a session.");
|
||||
blog(LOG_INFO, "[InvalidateSession] Invalidating a session.");
|
||||
_server.close(hdl, WebSocketCloseCode::SessionInvalidated, "Your session has been invalidated.");
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ void SettingsDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
auto conf = GetConfig();
|
||||
if (!conf) {
|
||||
blog(LOG_ERROR, "Unable to retreive config!");
|
||||
blog(LOG_ERROR, "[showEvent] Unable to retreive config!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ void SettingsDialog::FillSessionTable()
|
||||
{
|
||||
auto webSocketServer = GetWebSocketServer();
|
||||
if (!webSocketServer) {
|
||||
blog(LOG_ERROR, "Unable to fetch websocket server instance!");
|
||||
blog(LOG_ERROR, "[FillSessionTable] Unable to fetch websocket server instance!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ void SettingsDialog::FormAccepted()
|
||||
{
|
||||
auto conf = GetConfig();
|
||||
if (!conf) {
|
||||
blog(LOG_ERROR, "Unable to retreive config!");
|
||||
blog(LOG_ERROR, "[FormAccepted] Unable to retreive config!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ SettingsDialog *_settingsDialog = nullptr;
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
blog(LOG_INFO, "you can haz websockets (Version: %s | RPC Version: %d)", OBS_WEBSOCKET_VERSION, OBS_WEBSOCKET_RPC_VERSION);
|
||||
blog(LOG_INFO, "Qt version (compile-time): %s | Qt version (run-time): %s",
|
||||
blog(LOG_INFO, "[obs_module_load] you can haz websockets (Version: %s | RPC Version: %d)", OBS_WEBSOCKET_VERSION, OBS_WEBSOCKET_RPC_VERSION);
|
||||
blog(LOG_INFO, "[obs_module_load] Qt version (compile-time): %s | Qt version (run-time): %s",
|
||||
QT_VERSION_STR, qVersion());
|
||||
|
||||
_config = ConfigPtr(new Config());
|
||||
@ -55,7 +55,7 @@ bool obs_module_load(void)
|
||||
QObject::connect(menuAction, &QAction::triggered, [] { _settingsDialog->ToggleShowHide(); });
|
||||
|
||||
// Loading finished
|
||||
blog(LOG_INFO, "Module loaded.");
|
||||
blog(LOG_INFO, "[obs_module_load] Module loaded.");
|
||||
|
||||
if (_config->ServerEnabled)
|
||||
_webSocketServer->Start();
|
||||
@ -65,16 +65,16 @@ bool obs_module_load(void)
|
||||
|
||||
void obs_module_unload()
|
||||
{
|
||||
blog(LOG_INFO, "Shutting down...");
|
||||
blog(LOG_INFO, "[obs_module_unload] Shutting down...");
|
||||
|
||||
if (_webSocketServer->IsListening()) {
|
||||
blog(LOG_INFO, "WebSocket server is running. Stopping...");
|
||||
blog(LOG_INFO, "[obs_module_unload] WebSocket server is running. Stopping...");
|
||||
_webSocketServer->Stop();
|
||||
}
|
||||
|
||||
_config.reset();
|
||||
_webSocketServer.reset();
|
||||
blog(LOG_INFO, "Finished shutting down.");
|
||||
blog(LOG_INFO, "[obs_module_unload] Finished shutting down.");
|
||||
}
|
||||
|
||||
ConfigPtr GetConfig()
|
||||
|
Loading…
Reference in New Issue
Block a user