1
1
forked from 0ad/0ad

Show system_info.txt, console.txt, json file, userreport_hw.txt paths in the terminal when it's written to the disk.

Discussed with: @vladislavbelov
Idea by: @elexis
Differential Revsion: https://code.wildfiregames.com/D2212

This was SVN commit r26544.
This commit is contained in:
Stan 2022-03-05 17:28:00 +00:00
parent f3fbc86529
commit b9d3d00c50
7 changed files with 31 additions and 11 deletions

View File

@ -24,6 +24,7 @@
#include "graphics/TextRenderer.h"
#include "gui/CGUI.h"
#include "gui/GUIManager.h"
#include "lib/code_generation.h"
#include "lib/ogl.h"
#include "lib/timer.h"
#include "lib/utf8.h"
@ -636,7 +637,11 @@ void CConsole::SaveHistory()
static const char newline = '\n';
buffer.Append(&newline, 1);
}
g_VFS->CreateFile(m_HistoryFile, buffer.Data(), buffer.Size());
if (g_VFS->CreateFile(m_HistoryFile, buffer.Data(), buffer.Size()) == INFO::OK)
ONCE(debug_printf("FILES| Console command history written to %s\n", m_HistoryFile.string8().c_str()));
else
debug_printf("FILES| Failed to write console command history to %s\n", m_HistoryFile.string8().c_str());
}
static bool isUnprintableChar(SDL_Keysym key)

View File

@ -72,10 +72,11 @@ CLogger::CLogger()
{
OsPath mainlogPath(psLogDir() / (L"mainlog" + g_UniqueLogPostfix + L".html"));
m_MainLog = new std::ofstream(OsString(mainlogPath).c_str(), std::ofstream::out | std::ofstream::trunc);
debug_printf("Writing the mainlog at %s\n", mainlogPath.string8().c_str());
debug_printf("FILES| Main log written to %s\n", mainlogPath.string8().c_str());
OsPath interestinglogPath(psLogDir() / (L"interestinglog" + g_UniqueLogPostfix + L".html"));
m_InterestingLog = new std::ofstream(OsString(interestinglogPath).c_str(), std::ofstream::out | std::ofstream::trunc);
debug_printf("FILES| Interesting log written to %s\n", interestinglogPath.string8().c_str());
m_OwnsStreams = true;
m_UseDebugPrintf = true;

View File

@ -512,6 +512,7 @@ void EarlyInit()
debug_SetThreadName("main");
// add all debug_printf "tags" that we are interested in:
debug_filter_add("TIMER");
debug_filter_add("FILES");
timer_Init();

View File

@ -82,7 +82,7 @@ void CReplayLogger::StartGame(JS::MutableHandleValue attribs)
Script::SetProperty(rq, attribs, "mods", mods);
m_Directory = createDateIndexSubdirectory(VisualReplay::GetDirectoryPath());
debug_printf("Writing replay to %s\n", m_Directory.string8().c_str());
debug_printf("FILES| Replay written to %s\n", m_Directory.string8().c_str());
m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt").c_str(), std::ofstream::out | std::ofstream::trunc);
*m_Stream << "start " << Script::StringifyJSON(rq, attribs, false) << "\n";
@ -129,9 +129,15 @@ void CReplayLogger::SaveMetadata(const CSimulation2& simulation)
CreateDirectories(fileName.Parent(), 0700);
std::ofstream stream (OsString(fileName).c_str(), std::ofstream::out | std::ofstream::trunc);
stream << Script::StringifyJSON(rq, &metadata, false);
stream.close();
debug_printf("Saved replay metadata to %s\n", fileName.string8().c_str());
if (stream)
{
stream << Script::StringifyJSON(rq, &metadata, false);
stream.close();
debug_printf("FILES| Replay metadata written to %s\n", fileName.string8().c_str());
}
else
debug_printf("FILES| Failed to write replay metadata to %s\n", fileName.string8().c_str());
}
OsPath CReplayLogger::GetDirectory() const

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -616,12 +616,12 @@ void CUserReporter::SubmitReport(const std::string& type, int version, const std
std::ofstream stream(OsString(path), std::ofstream::trunc);
if (stream)
{
debug_printf("UserReport written to %s\n", path.string8().c_str());
debug_printf("FILES| UserReport written to %s\n", path.string8().c_str());
stream << dataHumanReadable << std::endl;
stream.close();
}
else
debug_printf("Failed to write UserReport to %s\n", path.string8().c_str());
debug_printf("FILES| Failed to write UserReport to %s\n", path.string8().c_str());
}
// If not initialised, discard the report

View File

@ -122,6 +122,8 @@ void WriteSystemInfo()
fclose(f);
f = 0;
debug_printf("FILES| Hardware details written to %s\n", pathname.string8().c_str());
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -224,7 +224,12 @@ void WriteJSONFile(const ScriptInterface& scriptInterface, const std::wstring& f
VfsPath path(filePath);
WriteBuffer buf;
buf.Append(str.c_str(), str.length());
g_VFS->CreateFile(path, buf.Data(), buf.Size());
OsPath realPath;
g_VFS->GetRealPath(path, realPath, false);
if (g_VFS->CreateFile(path, buf.Data(), buf.Size()) == INFO::OK)
debug_printf("FILES| JSON data written to %s\n", realPath.string8().c_str());
else
debug_printf("FILES| Failed to write JSON data to %s\n", realPath.string8().c_str());
}
bool DeleteCampaignSave(const CStrW& filePath)