From 031d6a3d88c714cd11884e73248f0c24090d50e1 Mon Sep 17 00:00:00 2001 From: Test_User Date: Thu, 10 Aug 2023 01:12:30 -0400 Subject: Log-related stuff --- client_network.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'client_network.c') diff --git a/client_network.c b/client_network.c index 3ddad6e..fe03eba 100644 --- a/client_network.c +++ b/client_network.c @@ -533,3 +533,35 @@ int initclientnetwork(void) { return 0; } + +#if LOGALL +ssize_t SENDCLIENT(struct string msg) { + if (!msg.len) + return 0; + + static char printprefix = 1; + if (printprefix) { +#if COLORIZE + WRITES(1, STRING("\x1b[31m[Us->Client] \x1b[32m")); +#else + WRITES(1, STRING("[Us->Client] ")); +#endif + + printprefix = 0; + } + + WRITES(1, msg); + + if (msg.data[msg.len - 1] == '\n') { + printprefix = 1; +#if COLORIZE + WRITES(1, STRING("\x1b[0m\n")); +#else + WRITES(1, STRING("\n")); +#endif + } + + + return WRITES(client_fd, msg); +} +#endif -- cgit v1.2.3