Simplify log initialization a little. Minor logging improvments in native. Don't disable logging in UWPMain

This commit is contained in:
Henrik Rydgård 2017-03-08 14:20:15 +01:00
parent 22782b6439
commit 5880f37598
6 changed files with 35 additions and 32 deletions

View File

@ -110,23 +110,27 @@ LogManager::LogManager() {
#endif
}
// Remove file logging on small devices
// Remove file logging on small devices in Release mode.
#if PPSSPP_PLATFORM(UWP)
if (IsDebuggerPresent())
debuggerLog_ = new OutputDebugStringLogListener();
#else
#if !defined(MOBILE_DEVICE) || defined(_DEBUG)
fileLog_ = new FileLogListener("");
consoleLog_ = new ConsoleListener();
debuggerLog_ = new DebuggerLogListener();
#else
fileLog_ = nullptr;
consoleLog_ = nullptr;
debuggerLog_ = nullptr;
#ifdef _WIN32
if (IsDebuggerPresent())
debuggerLog_ = new OutputDebugStringLogListener();
#endif
#endif
ringLog_ = new RingbufferLogListener();
#endif
#if !defined(MOBILE_DEVICE) || defined(_DEBUG)
AddListener(fileLog_);
AddListener(consoleLog_);
#if defined(_MSC_VER) && (defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP))
if (IsDebuggerPresent() && debuggerLog_ != NULL && LOG_MSC_OUTPUTDEBUG)
if (IsDebuggerPresent() && debuggerLog_ && LOG_MSC_OUTPUTDEBUG)
AddListener(debuggerLog_);
#endif
AddListener(ringLog_);
@ -292,7 +296,7 @@ void FileLogListener::Log(const LogMessage &message) {
m_logfile << message.header << " " << message.msg << std::flush;
}
void DebuggerLogListener::Log(const LogMessage &message) {
void OutputDebugStringLogListener::Log(const LogMessage &message) {
#if _MSC_VER
OutputDebugStringUTF8(message.msg.c_str());
#endif

View File

@ -66,7 +66,7 @@ private:
bool m_enable;
};
class DebuggerLogListener : public LogListener {
class OutputDebugStringLogListener : public LogListener {
public:
void Log(const LogMessage &msg);
};
@ -104,6 +104,20 @@ struct LogChannel {
class ConsoleListener;
class LogManager : NonCopyable {
private:
LogManager();
~LogManager();
LogChannel log_[LogTypes::NUMBER_OF_LOGS];
FileLogListener *fileLog_ = nullptr;
ConsoleListener *consoleLog_ = nullptr;
OutputDebugStringLogListener *debuggerLog_ = nullptr;
RingbufferLogListener *ringLog_ = nullptr;
static LogManager *logManager_; // Singleton. Ugh.
std::mutex log_lock_;
std::mutex listeners_lock_;
std::vector<LogListener*> listeners_;
public:
void AddListener(LogListener *listener);
void RemoveListener(LogListener *listener);
@ -141,7 +155,7 @@ public:
return consoleLog_;
}
DebuggerLogListener *GetDebuggerListener() const {
OutputDebugStringLogListener *GetDebuggerListener() const {
return debuggerLog_;
}
@ -164,19 +178,4 @@ public:
void SaveConfig(IniFile::Section *section);
void LoadConfig(IniFile::Section *section, bool debugDefaults);
private:
LogManager();
~LogManager();
LogChannel log_[LogTypes::NUMBER_OF_LOGS];
FileLogListener *fileLog_;
ConsoleListener *consoleLog_;
DebuggerLogListener *debuggerLog_;
RingbufferLogListener *ringLog_;
static LogManager *logManager_; // Singleton. Ugh.
std::mutex log_lock_;
std::mutex listeners_lock_;
std::vector<LogListener*> listeners_;
};

View File

@ -396,6 +396,7 @@
<ClCompile Include="..\..\ext\native\base\colorutil.cpp" />
<ClCompile Include="..\..\ext\native\base\compat.cpp" />
<ClCompile Include="..\..\ext\native\base\display.cpp" />
<ClCompile Include="..\..\ext\native\base\logging.cpp" />
<ClCompile Include="..\..\ext\native\base\stringutil.cpp" />
<ClCompile Include="..\..\ext\native\base\timeutil.cpp" />
<ClCompile Include="..\..\ext\native\data\compression.cpp" />

View File

@ -454,6 +454,9 @@
<ClCompile Include="..\..\ext\native\gfx\gl_lost_manager.cpp">
<Filter>gfx</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\base\logging.cpp">
<Filter>base</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />

View File

@ -110,10 +110,6 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
g_Config.iGPUBackend = GPU_BACKEND_DIRECT3D11;
g_Config.bSeparateCPUThread = false;
#ifdef _DEBUG
g_Config.bEnableLogging = false;
#endif
if (debugLogLevel) {
LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG);
}

View File

@ -345,7 +345,7 @@ static bool IsLocalPath(const char *path) {
uint8_t *VFSReadFile(const char *filename, size_t *size) {
if (IsLocalPath(filename)) {
// Local path, not VFS.
ILOG("Not a VFS path: %s . Reading local file.", filename);
// ILOG("Not a VFS path: %s . Reading local file.", filename);
return ReadLocalFile(filename, size);
}
@ -374,7 +374,7 @@ uint8_t *VFSReadFile(const char *filename, size_t *size) {
bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const char *filter) {
if (IsLocalPath(path)) {
// Local path, not VFS.
ILOG("Not a VFS path: %s . Reading local directory.", path);
// ILOG("Not a VFS path: %s . Reading local directory.", path);
getFilesInDir(path, listing, filter);
return true;
}
@ -401,7 +401,7 @@ bool VFSGetFileListing(const char *path, std::vector<FileInfo> *listing, const c
bool VFSGetFileInfo(const char *path, FileInfo *info) {
if (IsLocalPath(path)) {
// Local path, not VFS.
ILOG("Not a VFS path: %s . Getting local file info.", path);
// ILOG("Not a VFS path: %s . Getting local file info.", path);
return getFileInfo(path, info);
}