| 152 | void SetLogCB(LogCallback cb) { LogCB = cb; } |
| 153 | |
| 154 | void CreateLog(BOOL nl) |
| 155 | { |
| 156 | if (!nl) |
| 157 | { |
| 158 | std::cout.rdbuf(logstream.rdbuf()); // redirect std::cout to log |
| 159 | |
| 160 | if (!strstr(Core.Params, "-no_unique_logs")) |
| 161 | { |
| 162 | string32 TimeBuf; |
| 163 | using namespace std::chrono; |
| 164 | const auto now = system_clock::now(); |
| 165 | const auto time = system_clock::to_time_t(now); |
| 166 | std::strftime(TimeBuf, sizeof(TimeBuf), "%d-%m-%y_%H-%M-%S", std::localtime(&time)); |
| 167 | |
| 168 | xr_strconcat(logFName, Core.ApplicationName, "_", Core.UserName, "_", TimeBuf, ".log"); |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | xr_strconcat(logFName, Core.ApplicationName, "_", Core.UserName, ".log"); |
| 173 | } |
| 174 | |
| 175 | try |
| 176 | { |
| 177 | if (FS.path_exist("$logs$")) |
| 178 | { |
| 179 | FS.update_path(logFName, "$logs$", logFName); |
| 180 | } |
| 181 | else |
| 182 | { //Для компрессора |
| 183 | string_path temp; |
| 184 | strcpy_s(temp, logFName); |
| 185 | xr_strconcat(logFName, "logs\\", temp); |
| 186 | } |
| 187 | |
| 188 | //logstream.imbue(std::locale("")); |
| 189 | VerifyPath(logFName); |
| 190 | logstream.open(logFName); |
| 191 | } |
| 192 | catch (...) |
| 193 | { |
| 194 | Debug.do_exit("Can't create log file!"); |
| 195 | } |
| 196 | |
| 197 | for (const auto& str : LogFile) |
| 198 | logstream << str; |
| 199 | |
| 200 | logstream.flush(); |
| 201 | } |
| 202 | |
| 203 | LogFile.reserve(5000); |
| 204 | } |
no test coverage detected