MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / SetFileOutputLevel

Method SetFileOutputLevel

common/Console.cpp:342–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342bool Log::SetFileOutputLevel(LOGLEVEL level, std::string path)
343{
344 std::unique_lock lock(s_file_mutex);
345
346 const bool was_enabled = (s_file_level > LOGLEVEL_NONE);
347 const bool new_enabled = (level > LOGLEVEL_NONE && !path.empty());
348 if (was_enabled != new_enabled || (new_enabled && path != s_file_path))
349 {
350 if (new_enabled)
351 {
352 if (!s_file_handle || s_file_path != path)
353 {
354 s_file_handle.reset();
355 s_file_handle = FileSystem::OpenManagedSharedCFile(path.c_str(), "wb", FileSystem::FileShareMode::DenyWrite);
356 if (s_file_handle)
357 {
358 s_file_path = std::move(path);
359 }
360 else
361 {
362 s_file_path = {};
363
364 if (IsConsoleOutputEnabled())
365 WriteToConsole(LOGLEVEL_ERROR, Color_StrongRed, TinyString::from_format("Failed to open log file '{}'", path));
366 }
367 }
368 }
369 else
370 {
371 s_file_handle.reset();
372 s_file_path = {};
373 }
374 }
375
376 s_file_level = s_file_handle ? level : LOGLEVEL_NONE;
377 UpdateMaxLevel();
378 return IsFileOutputEnabled();
379}
380
381std::FILE* Log::GetFileLogHandle()
382{

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
resetMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected