aboutsummaryrefslogtreecommitdiff
path: root/data/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'data/client.cpp')
-rw-r--r--data/client.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/data/client.cpp b/data/client.cpp
index 65494b0..2a162f2 100644
--- a/data/client.cpp
+++ b/data/client.cpp
@@ -4,14 +4,12 @@
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <implot.h>
+#include <initializer_list>
#include <json-c/json.h>
#include <limits.h>
#include <math.h>
#include <signal.h>
#include <threads.h>
-
-#include <initializer_list>
-
#include "logger.c"
#define FETCH_INTERVAL 10
@@ -187,7 +185,7 @@ void data_fetch(void) {
json_object_object_add(request, "x-current", json_object_new_int(g_x_current));
const char *request_str = json_object_to_json_string(request);
- log_info("Sending request to server: %s", request_str);
+ g_info("Sending request to server: %s", request_str);
int socket_fd = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in socket_addr;
memset(&socket_addr, 0, sizeof(struct sockaddr_in));
@@ -200,7 +198,7 @@ void data_fetch(void) {
struct json_object *response = json_object_from_fd(socket_fd);
const char *response_str = json_object_to_json_string(response);
- log_info("Server responded with: %s", response_str);
+ g_info("Server responded with: %s", response_str);
json_object_put(request);
json_object_put(response);
@@ -225,14 +223,14 @@ int data_fetching_thread(void *data) {
}
void data_start_fetching(void) {
- log_info("Starting data fetching thread");
+ g_info("Starting data fetching thread");
g_status = STATUS_RUNNING;
thrd_create(&g_data_fetching_thread, (thrd_start_t)data_fetching_thread, nullptr);
}
void data_stop_fetching(void) {
assert(g_status == STATUS_RUNNING);
- log_info("Stopping data fetching thread");
+ g_info("Stopping data fetching thread");
g_status = STATUS_STOPPING;
thrd_join(g_data_fetching_thread, nullptr);
}
@@ -412,13 +410,13 @@ void gui_print(void) {
void sig_handler(int signo) {
(void)signo;
- log_warn("Signal received, will stop SALIS data client...");
+ g_warn("Signal received, will stop SALIS data client...");
if (g_status == STATUS_RUNNING) data_stop_fetching();
glfwSetWindowShouldClose(g_window, GLFW_TRUE);
}
void glfw_error_callback(int error, const char* description) {
- log_warn("GLFW error %d: %s", error, description);
+ g_warn("GLFW error %d: %s", error, description);
}
void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
@@ -506,9 +504,9 @@ int main(int argc, char **argv) {
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
- log_info("Starting SALIS data client");
+ g_info("Starting SALIS data client");
- log_info("Initializing GLFW");
+ g_info("Initializing GLFW");
glfwSetErrorCallback(glfw_error_callback);
glfwInitHint(GLFW_WAYLAND_LIBDECOR, GLFW_WAYLAND_DISABLE_LIBDECOR);
if (!glfwInit()) assert(false);
@@ -520,7 +518,7 @@ int main(int argc, char **argv) {
glfwMakeContextCurrent(g_window);
glfwSwapInterval(1); // enable vsync
- log_info("Initializing ImGui");
+ g_info("Initializing ImGui");
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImPlot::CreateContext();
@@ -569,7 +567,7 @@ int main(int argc, char **argv) {
ImPlot::DestroyContext();
ImGui::DestroyContext();
- log_info("Stopping SALIS data client");
+ g_info("Stopping SALIS data client");
glfwDestroyWindow(g_window);
glfwTerminate();
return 0;