Introduce CLogger::ScopedReplacement and FileLogger

Comments By: @sera, @vladislavbelov, @Stan
Differential Revision: https://code.wildfiregames.com/D5167
This was SVN commit r27953.
This commit is contained in:
phosit
2023-11-23 20:42:18 +00:00
parent 63a4799f56
commit 949be94aab
6 changed files with 82 additions and 49 deletions
+2 -15
View File
@@ -155,12 +155,10 @@ void MountMods(const Paths& paths, const std::vector<CStr>& mods)
g_VFS->Mount(L"", modUserPath / "user" / "", userFlags, InDevelopmentCopy() ? 0 : priority + 1);
}
static void InitVfs(const CmdLineArgs& args, int flags)
void InitVfs(const CmdLineArgs& args)
{
TIMER(L"InitVfs");
const bool setup_error = (flags & INIT_HAVE_DISPLAY_ERROR) == 0;
const Paths paths(args);
OsPath logs(paths.Logs());
@@ -172,8 +170,7 @@ static void InitVfs(const CmdLineArgs& args, int flags)
AppHooks hooks = {0};
hooks.bundle_logs = psBundleLogs;
hooks.get_log_dir = psLogDir;
if (setup_error)
hooks.display_error = psDisplayError;
hooks.display_error = psDisplayError;
app_hooks_update(&hooks);
g_VFS = CreateVfs();
@@ -407,7 +404,6 @@ from_config:
CNetHost::Deinitialize();
// should be last, since the above use them
SAFE_DELETE(g_Logger);
delete &g_Profiler;
delete &g_ProfileViewer;
@@ -523,15 +519,6 @@ bool AutostartVisualReplay(const std::string& replayFile);
bool Init(const CmdLineArgs& args, int flags)
{
// Do this as soon as possible, because it chdirs
// and will mess up the error reporting if anything
// crashes before the working directory is set.
InitVfs(args, flags);
// This must come after VFS init, which sets the current directory
// (required for finding our output log files).
g_Logger = new CLogger;
new CProfileViewer;
new CProfileManager; // before any script code