MCPcopy Create free account
hub / github.com/Norbyte/bg3se / MakeLogFilePath

Method MakeLogFilePath

BG3Extender/Extender/ScriptExtender.cpp:202–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202std::wstring ScriptExtender::MakeLogFilePath(std::wstring const & Type, std::wstring const & Extension)
203{
204 if (config_.LogDirectory.empty()) {
205 config_.LogDirectory = FromUTF8(GetStaticSymbols().ToPath("/Script Extender Logs", PathRootType::UserProfile));
206 }
207
208 if (config_.LogDirectory.empty()) {
209 return L"";
210 }
211
212 BOOL created = CreateDirectoryW(config_.LogDirectory.c_str(), NULL);
213 if (created == FALSE) {
214 DWORD lastError = GetLastError();
215 if (lastError != ERROR_ALREADY_EXISTS) {
216 std::wstringstream err;
217 err << L"Could not create log directory '" << config_.LogDirectory << "': Error " << lastError;
218 return L"";
219 }
220 }
221
222 auto now = std::chrono::system_clock::now();
223 auto tt = std::chrono::system_clock::to_time_t(now);
224 std::tm tm;
225 gmtime_s(&tm, &tt);
226
227 std::wstringstream ss;
228 ss << config_.LogDirectory << L"\\"
229 << Type << L" "
230 << std::setfill(L'0')
231 << (tm.tm_year + 1900) << L"-"
232 << std::setw(2) << (tm.tm_mon + 1) << L"-"
233 << std::setw(2) << tm.tm_mday << L" "
234 << std::setw(2) << tm.tm_hour << L"-"
235 << std::setw(2) << tm.tm_min << L"-"
236 << std::setw(2) << tm.tm_sec << L"." << Extension;
237 return ss.str();
238}
239
240void ScriptExtender::OnStatsLoadGuarded(stats::RPGStats::LoadProc* wrapped, stats::RPGStats* mgr, Array<STDString>* paths)
241{

Callers 3

RestartLoggingMethod · 0.80
CompileWrapperMethod · 0.80
InitRuntimeLoggingMethod · 0.80

Calls 3

ToPathMethod · 0.80
FromUTF8Function · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected