MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / AppendChatLog

Function AppendChatLog

src/Chat.c:158–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static void AppendChatLog(const cc_string* text) {
159 cc_string str; char strBuffer[DRAWER2D_MAX_TEXT_LENGTH];
160 struct cc_datetime now;
161 cc_result res;
162
163 if (!logName.length || !Chat_Logging) return;
164 DateTime_CurrentLocal(&now);
165
166 if (now.day != lastLogDay || now.month != lastLogMonth || now.year != lastLogYear) {
167 CloseLogFile();
168 OpenChatLog(&now);
169 }
170
171 lastLogDay = now.day; lastLogMonth = now.month; lastLogYear = now.year;
172 if (!logStream.meta.file) return;
173
174 /* [HH:mm:ss] text */
175 String_InitArray(str, strBuffer);
176 String_Format3(&str, "[%p2:%p2:%p2] ", &now.hour, &now.minute, &now.second);
177 Drawer2D_WithoutColors(&str, text);
178
179 res = Stream_WriteLine(&logStream, &str);
180 if (!res) return;
181 Chat_DisableLogging();
182 Logger_SysWarn2(res, "writing to", &logPath);
183}
184
185void Chat_Add1(const char* format, const void* a1) {
186 Chat_Add4(format, a1, NULL, NULL, NULL);

Callers 1

Chat_AddOfFunction · 0.85

Calls 8

OpenChatLogFunction · 0.85
String_Format3Function · 0.85
Drawer2D_WithoutColorsFunction · 0.85
Stream_WriteLineFunction · 0.85
Chat_DisableLoggingFunction · 0.85
Logger_SysWarn2Function · 0.85
DateTime_CurrentLocalFunction · 0.70
CloseLogFileFunction · 0.70

Tested by

no test coverage detected