| 156 | } |
| 157 | |
| 158 | static 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 | |
| 185 | void Chat_Add1(const char* format, const void* a1) { |
| 186 | Chat_Add4(format, a1, NULL, NULL, NULL); |
no test coverage detected