diff options
author | Test_User <hax@andrewyu.org> | 2023-08-10 01:12:30 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2023-08-10 01:12:30 -0400 |
commit | 031d6a3d88c714cd11884e73248f0c24090d50e1 (patch) | |
tree | e7e90ba77dea37ccee34cd7f2e0838e2dec8e956 /client_network.c | |
parent | ffc06e4614772a681114d4059a072f599ee378f8 (diff) | |
download | c_coupserv-031d6a3d88c714cd11884e73248f0c24090d50e1.tar.gz c_coupserv-031d6a3d88c714cd11884e73248f0c24090d50e1.zip |
Log-related stuff
Diffstat (limited to 'client_network.c')
-rw-r--r-- | client_network.c | 32 |
1 files changed, 32 insertions, 0 deletions
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 |