mirror of https://github.com/AxioDL/metaforce.git
Add `-l` flag to enable logging
This commit is contained in:
parent
172a0049cc
commit
3522d757fc
|
@ -4,6 +4,7 @@
|
||||||
#include "hecl/CVarManager.hpp"
|
#include "hecl/CVarManager.hpp"
|
||||||
#include "Runtime/CBasics.hpp"
|
#include "Runtime/CBasics.hpp"
|
||||||
#include "ViewManager.hpp"
|
#include "ViewManager.hpp"
|
||||||
|
#include "hecl/hecl.hpp"
|
||||||
|
|
||||||
static logvisor::Module AthenaLog("Athena");
|
static logvisor::Module AthenaLog("Athena");
|
||||||
static void AthenaExc(athena::error::Level level, const char* file,
|
static void AthenaExc(athena::error::Level level, const char* file,
|
||||||
|
@ -125,20 +126,33 @@ struct Application : boo::IApplicationCallback
|
||||||
static hecl::SystemChar CwdBuf[1024];
|
static hecl::SystemChar CwdBuf[1024];
|
||||||
hecl::SystemString ExeDir;
|
hecl::SystemString ExeDir;
|
||||||
|
|
||||||
void SetupBasics()
|
static void SetupBasics(bool logging)
|
||||||
{
|
{
|
||||||
logvisor::RegisterStandardExceptions();
|
logvisor::RegisterStandardExceptions();
|
||||||
logvisor::RegisterConsoleLogger();
|
if (logging)
|
||||||
|
logvisor::RegisterConsoleLogger();
|
||||||
atSetExceptionHandler(AthenaExc);
|
atSetExceptionHandler(AthenaExc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsClientLoggingEnabled(int argc, const boo::SystemChar** argv)
|
||||||
|
{
|
||||||
|
bool logging = false;
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
if (!hecl::StrNCmp(argv[i], _S("-l"), 2))
|
||||||
|
{
|
||||||
|
logging = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return logging;
|
||||||
|
}
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
int wmain(int argc, const boo::SystemChar** argv)
|
int wmain(int argc, const boo::SystemChar** argv)
|
||||||
#else
|
#else
|
||||||
int main(int argc, const boo::SystemChar** argv)
|
int main(int argc, const boo::SystemChar** argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SetupBasics();
|
SetupBasics(IsClientLoggingEnabled(argc, argv));
|
||||||
|
|
||||||
if (hecl::SystemChar* cwd = hecl::Getcwd(CwdBuf, 1024))
|
if (hecl::SystemChar* cwd = hecl::Getcwd(CwdBuf, 1024))
|
||||||
{
|
{
|
||||||
|
@ -182,7 +196,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
|
||||||
for (int i=0 ; i<argc ; ++i)
|
for (int i=0 ; i<argc ; ++i)
|
||||||
booArgv[i+1] = argv[i];
|
booArgv[i+1] = argv[i];
|
||||||
|
|
||||||
logvisor::CreateWin32Console();
|
if (IsClientLoggingEnabled(argc+1, booArgv))
|
||||||
|
logvisor::CreateWin32Console();
|
||||||
return wmain(argc+1, booArgv);
|
return wmain(argc+1, booArgv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "CDvdFile.hpp"
|
#include "CDvdFile.hpp"
|
||||||
#include "CDvdRequest.hpp"
|
#include "CDvdRequest.hpp"
|
||||||
|
#include "CStopwatch.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "CFactoryMgr.hpp"
|
#include "CFactoryMgr.hpp"
|
||||||
#include "IObj.hpp"
|
#include "IObj.hpp"
|
||||||
|
#include "CStopwatch.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,6 +65,7 @@ add_library(RuntimeCommon
|
||||||
${WEAPON_SOURCES}
|
${WEAPON_SOURCES}
|
||||||
ITweak.hpp
|
ITweak.hpp
|
||||||
IMain.hpp
|
IMain.hpp
|
||||||
|
CStopwatch.hpp
|
||||||
CGameAllocator.hpp CGameAllocator.cpp
|
CGameAllocator.hpp CGameAllocator.cpp
|
||||||
CMemoryCardSys.hpp CMemoryCardSys.cpp
|
CMemoryCardSys.hpp CMemoryCardSys.cpp
|
||||||
CScannableObjectInfo.hpp CScannableObjectInfo.cpp
|
CScannableObjectInfo.hpp CScannableObjectInfo.cpp
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "CResFactory.hpp"
|
#include "CResFactory.hpp"
|
||||||
#include "CSimplePool.hpp"
|
#include "CSimplePool.hpp"
|
||||||
|
#include "CStopwatch.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef __URDE_CSTOPWATCH_HPP__
|
||||||
|
#define __URDE_CSTOPWATCH_HPP__
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace urde
|
||||||
|
{
|
||||||
|
class CStopwatch
|
||||||
|
{
|
||||||
|
std::chrono::steady_clock::time_point m_start;
|
||||||
|
public:
|
||||||
|
CStopwatch() : m_start(std::chrono::steady_clock::now()) {}
|
||||||
|
void report(const char* name) const
|
||||||
|
{
|
||||||
|
printf("%s %f\n", name, std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
|
std::chrono::steady_clock::now() - m_start).count() / 1000000.f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __URDE_CSTOPWATCH_HPP__
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit fd8b53d626cf1204c8d6dea80f64573afc8e784a
|
Subproject commit 5f21d60814dcd2dbb5d58db7e78b5efb04435c39
|
2
nod
2
nod
|
@ -1 +1 @@
|
||||||
Subproject commit b5916af70270185fb6aba5db8f670859483ffa4f
|
Subproject commit e20fce1e6f45b5dd2740fa4544a9f8471a1d52c0
|
Loading…
Reference in New Issue