MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / CreateLog

Function CreateLog

ogsr_engine/xrCore/log.cpp:154–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152void SetLogCB(LogCallback cb) { LogCB = cb; }
153
154void 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}

Callers 1

_initializeMethod · 0.85

Calls 8

xr_strconcatFunction · 0.85
VerifyPathFunction · 0.85
path_existMethod · 0.80
do_exitMethod · 0.80
update_pathMethod · 0.45
openMethod · 0.45
flushMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected