Add ability to log to file

This commit is contained in:
Phillip Stephens 2020-09-05 18:32:12 -07:00
parent 2a8a9ea66f
commit b28b19732e
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
2 changed files with 21 additions and 9 deletions

View File

@ -48,17 +48,17 @@ static hecl::SystemString CPUFeatureString(const zeus::CPUInfo& cpuInf) {
} }
struct Application : boo::IApplicationCallback { struct Application : boo::IApplicationCallback {
hecl::Runtime::FileStoreManager m_fileMgr; hecl::Runtime::FileStoreManager& m_fileMgr;
hecl::CVarManager m_cvarManager; hecl::CVarManager& m_cvarManager;
hecl::CVarCommons m_cvarCommons; hecl::CVarCommons& m_cvarCommons;
std::unique_ptr<ViewManager> m_viewManager; std::unique_ptr<ViewManager> m_viewManager;
std::atomic_bool m_running = {true}; std::atomic_bool m_running = {true};
Application() Application(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCmns)
: m_fileMgr(_SYS_STR("urde")) : m_fileMgr(fileMgr)
, m_cvarManager(m_fileMgr) , m_cvarManager(cvarMgr)
, m_cvarCommons(m_cvarManager) , m_cvarCommons(cvarCmns)
, m_viewManager(std::make_unique<ViewManager>(m_fileMgr, m_cvarManager)) {} , m_viewManager(std::make_unique<ViewManager>(m_fileMgr, m_cvarManager)) {}
virtual ~Application() = default; virtual ~Application() = default;
@ -89,6 +89,7 @@ struct Application : boo::IApplicationCallback {
void initialize(boo::IApplication* app) { void initialize(boo::IApplication* app) {
zeus::detectCPU(); zeus::detectCPU();
for (const boo::SystemString& arg : app->getArgs()) { for (const boo::SystemString& arg : app->getArgs()) {
if (arg.find(_SYS_STR("--verbosity=")) == 0 || arg.find(_SYS_STR("-v=")) == 0) { if (arg.find(_SYS_STR("--verbosity=")) == 0 || arg.find(_SYS_STR("-v=")) == 0) {
hecl::SystemUTF8Conv utf8Arg(arg.substr(arg.find_last_of('=') + 1)); hecl::SystemUTF8Conv utf8Arg(arg.substr(arg.find_last_of('=') + 1));
@ -159,6 +160,17 @@ int main(int argc, const boo::SystemChar** argv)
} }
SetupBasics(IsClientLoggingEnabled(argc, argv)); SetupBasics(IsClientLoggingEnabled(argc, argv));
hecl::Runtime::FileStoreManager fileMgr{_SYS_STR("urde")};
hecl::CVarManager cvarMgr{fileMgr};
hecl::CVarCommons cvarCmns{cvarMgr};
hecl::SystemStringView logFile = hecl::SystemStringConv(cvarCmns.getLogFile()).sys_str();
hecl::SystemString logFilePath;
if (!logFile.empty()) {
logFilePath = fmt::format(FMT_STRING(_SYS_STR("{}/{}")), fileMgr.getStoreRoot(), logFile);
fmt::print(FMT_STRING("{}\n"), logFilePath);
logvisor::RegisterFileLogger(logFilePath.c_str());
}
if (hecl::SystemChar* cwd = hecl::Getcwd(CwdBuf, 1024)) { if (hecl::SystemChar* cwd = hecl::Getcwd(CwdBuf, 1024)) {
if (hecl::PathRelative(argv[0])) if (hecl::PathRelative(argv[0]))
@ -172,7 +184,7 @@ int main(int argc, const boo::SystemChar** argv)
/* Handle -j argument */ /* Handle -j argument */
hecl::SetCpuCountOverride(argc, argv); hecl::SetCpuCountOverride(argc, argv);
urde::Application appCb; urde::Application appCb(fileMgr, cvarMgr, cvarCmns);
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, _SYS_STR("urde"), _SYS_STR("URDE"), argc, int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, _SYS_STR("urde"), _SYS_STR("URDE"), argc,
argv, appCb.getGraphicsApi(), appCb.getSamples(), appCb.getAnisotropy(), argv, appCb.getGraphicsApi(), appCb.getSamples(), appCb.getAnisotropy(),
appCb.getDeepColor(), false); appCb.getDeepColor(), false);

2
hecl

@ -1 +1 @@
Subproject commit 466ffb194fab90da256e9d6f126555ede453033b Subproject commit 06848e55532a4841ade0c373eb8d33550f4fcce8