diff options
| author | 2014-12-06 21:14:14 -0200 | |
|---|---|---|
| committer | 2014-12-13 02:08:06 -0200 | |
| commit | 4d2a6f8b9b3eeb85574a5e4f93422ffd4feebcd3 (patch) | |
| tree | 1e3fd71256c04a15970b09abd3f7280f8b1ff678 /src/common/log_manager.cpp | |
| parent | Add configurable per-class log filtering (diff) | |
| download | yuzu-4d2a6f8b9b3eeb85574a5e4f93422ffd4feebcd3.tar.gz yuzu-4d2a6f8b9b3eeb85574a5e4f93422ffd4feebcd3.tar.xz yuzu-4d2a6f8b9b3eeb85574a5e4f93422ffd4feebcd3.zip | |
Remove old logging system
Diffstat (limited to 'src/common/log_manager.cpp')
| -rw-r--r-- | src/common/log_manager.cpp | 198 |
1 files changed, 0 insertions, 198 deletions
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp deleted file mode 100644 index adc17444c..000000000 --- a/src/common/log_manager.cpp +++ /dev/null | |||
| @@ -1,198 +0,0 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | |||
| 7 | #include "common/log_manager.h" | ||
| 8 | #include "common/console_listener.h" | ||
| 9 | #include "common/timer.h" | ||
| 10 | |||
| 11 | void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, | ||
| 12 | const char* function, const char* fmt, ...) | ||
| 13 | { | ||
| 14 | va_list args; | ||
| 15 | va_start(args, fmt); | ||
| 16 | |||
| 17 | if (LogManager::GetInstance()) { | ||
| 18 | LogManager::GetInstance()->Log(level, type, | ||
| 19 | file, line, function, fmt, args); | ||
| 20 | } | ||
| 21 | va_end(args); | ||
| 22 | } | ||
| 23 | |||
| 24 | LogManager *LogManager::m_logManager = nullptr; | ||
| 25 | |||
| 26 | LogManager::LogManager() | ||
| 27 | { | ||
| 28 | // create log files | ||
| 29 | m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log"); | ||
| 30 | m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot"); | ||
| 31 | m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common"); | ||
| 32 | m_Log[LogTypes::CONFIG] = new LogContainer("CONFIG", "Configuration"); | ||
| 33 | //m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO"); | ||
| 34 | //m_Log[LogTypes::FILEMON] = new LogContainer("FileMon", "File Monitor"); | ||
| 35 | //m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad"); | ||
| 36 | //m_Log[LogTypes::PIXELENGINE] = new LogContainer("PE", "PixelEngine"); | ||
| 37 | //m_Log[LogTypes::COMMANDPROCESSOR] = new LogContainer("CP", "CommandProc"); | ||
| 38 | //m_Log[LogTypes::VIDEOINTERFACE] = new LogContainer("VI", "VideoInt"); | ||
| 39 | //m_Log[LogTypes::SERIALINTERFACE] = new LogContainer("SI", "SerialInt"); | ||
| 40 | //m_Log[LogTypes::PROCESSORINTERFACE] = new LogContainer("PI", "ProcessorInt"); | ||
| 41 | m_Log[LogTypes::MEMMAP] = new LogContainer("MI", "MI & memmap"); | ||
| 42 | //m_Log[LogTypes::SP1] = new LogContainer("SP1", "Serial Port 1"); | ||
| 43 | //m_Log[LogTypes::STREAMINGINTERFACE] = new LogContainer("Stream", "StreamingInt"); | ||
| 44 | //m_Log[LogTypes::DSPINTERFACE] = new LogContainer("DSP", "DSPInterface"); | ||
| 45 | //m_Log[LogTypes::DVDINTERFACE] = new LogContainer("DVD", "DVDInterface"); | ||
| 46 | m_Log[LogTypes::GSP] = new LogContainer("GSP", "GSP"); | ||
| 47 | //m_Log[LogTypes::EXPANSIONINTERFACE] = new LogContainer("EXI", "ExpansionInt"); | ||
| 48 | //m_Log[LogTypes::GDB_STUB] = new LogContainer("GDB_STUB", "GDB Stub"); | ||
| 49 | //m_Log[LogTypes::AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt"); | ||
| 50 | m_Log[LogTypes::ARM11] = new LogContainer("ARM11", "ARM11"); | ||
| 51 | m_Log[LogTypes::OSHLE] = new LogContainer("HLE", "HLE"); | ||
| 52 | //m_Log[LogTypes::DSPHLE] = new LogContainer("DSPHLE", "DSP HLE"); | ||
| 53 | //m_Log[LogTypes::DSPLLE] = new LogContainer("DSPLLE", "DSP LLE"); | ||
| 54 | //m_Log[LogTypes::DSP_MAIL] = new LogContainer("DSPMails", "DSP Mails"); | ||
| 55 | m_Log[LogTypes::VIDEO] = new LogContainer("Video", "Video Backend"); | ||
| 56 | //m_Log[LogTypes::AUDIO] = new LogContainer("Audio", "Audio Emulator"); | ||
| 57 | //m_Log[LogTypes::DYNA_REC] = new LogContainer("JIT", "JIT"); | ||
| 58 | //m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console"); | ||
| 59 | //m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport"); | ||
| 60 | m_Log[LogTypes::TIME] = new LogContainer("Time", "Core Timing"); | ||
| 61 | m_Log[LogTypes::LOADER] = new LogContainer("Loader", "Loader"); | ||
| 62 | m_Log[LogTypes::FILESYS] = new LogContainer("FileSys", "File System"); | ||
| 63 | //m_Log[LogTypes::WII_IPC_HID] = new LogContainer("WII_IPC_HID", "WII IPC HID"); | ||
| 64 | m_Log[LogTypes::KERNEL] = new LogContainer("KERNEL", "KERNEL HLE"); | ||
| 65 | //m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD"); | ||
| 66 | //m_Log[LogTypes::WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES"); | ||
| 67 | //m_Log[LogTypes::WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO", "WII IPC FILEIO"); | ||
| 68 | m_Log[LogTypes::RENDER] = new LogContainer("RENDER", "RENDER"); | ||
| 69 | m_Log[LogTypes::GPU] = new LogContainer("GPU", "GPU"); | ||
| 70 | m_Log[LogTypes::SVC] = new LogContainer("SVC", "Supervisor Call HLE"); | ||
| 71 | m_Log[LogTypes::HLE] = new LogContainer("HLE", "High Level Emulation"); | ||
| 72 | m_Log[LogTypes::HW] = new LogContainer("HW", "Hardware"); | ||
| 73 | //m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); | ||
| 74 | //m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); | ||
| 75 | //m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); | ||
| 76 | m_Log[LogTypes::GUI] = new LogContainer("GUI", "GUI"); | ||
| 77 | |||
| 78 | m_fileLog = new FileLogListener(FileUtil::GetUserPath(F_MAINLOG_IDX).c_str()); | ||
| 79 | m_consoleLog = new ConsoleListener(); | ||
| 80 | m_debuggerLog = new DebuggerLogListener(); | ||
| 81 | |||
| 82 | for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) | ||
| 83 | { | ||
| 84 | m_Log[i]->SetEnable(true); | ||
| 85 | m_Log[i]->AddListener(m_fileLog); | ||
| 86 | m_Log[i]->AddListener(m_consoleLog); | ||
| 87 | #ifdef _MSC_VER | ||
| 88 | if (IsDebuggerPresent()) | ||
| 89 | m_Log[i]->AddListener(m_debuggerLog); | ||
| 90 | #endif | ||
| 91 | } | ||
| 92 | |||
| 93 | m_consoleLog->Open(); | ||
| 94 | } | ||
| 95 | |||
| 96 | LogManager::~LogManager() | ||
| 97 | { | ||
| 98 | for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) | ||
| 99 | { | ||
| 100 | m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog); | ||
| 101 | m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog); | ||
| 102 | m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog); | ||
| 103 | } | ||
| 104 | |||
| 105 | for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) | ||
| 106 | delete m_Log[i]; | ||
| 107 | |||
| 108 | delete m_fileLog; | ||
| 109 | delete m_consoleLog; | ||
| 110 | delete m_debuggerLog; | ||
| 111 | } | ||
| 112 | |||
| 113 | void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, | ||
| 114 | int line, const char* function, const char *fmt, va_list args) | ||
| 115 | { | ||
| 116 | char temp[MAX_MSGLEN]; | ||
| 117 | char msg[MAX_MSGLEN * 2]; | ||
| 118 | LogContainer *log = m_Log[type]; | ||
| 119 | |||
| 120 | if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) | ||
| 121 | return; | ||
| 122 | |||
| 123 | Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); | ||
| 124 | |||
| 125 | static const char level_to_char[7] = "ONEWID"; | ||
| 126 | sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, | ||
| 127 | level_to_char[(int)level], log->GetShortName(), function, temp); | ||
| 128 | |||
| 129 | #ifdef ANDROID | ||
| 130 | Host_SysMessage(msg); | ||
| 131 | #endif | ||
| 132 | log->Trigger(level, msg); | ||
| 133 | } | ||
| 134 | |||
| 135 | void LogManager::Init() | ||
| 136 | { | ||
| 137 | m_logManager = new LogManager(); | ||
| 138 | } | ||
| 139 | |||
| 140 | void LogManager::Shutdown() | ||
| 141 | { | ||
| 142 | delete m_logManager; | ||
| 143 | m_logManager = nullptr; | ||
| 144 | } | ||
| 145 | |||
| 146 | LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable) | ||
| 147 | : m_enable(enable) | ||
| 148 | { | ||
| 149 | strncpy(m_fullName, fullName, 128); | ||
| 150 | strncpy(m_shortName, shortName, 32); | ||
| 151 | m_level = LogTypes::MAX_LOGLEVEL; | ||
| 152 | } | ||
| 153 | |||
| 154 | // LogContainer | ||
| 155 | void LogContainer::AddListener(LogListener *listener) | ||
| 156 | { | ||
| 157 | std::lock_guard<std::mutex> lk(m_listeners_lock); | ||
| 158 | m_listeners.insert(listener); | ||
| 159 | } | ||
| 160 | |||
| 161 | void LogContainer::RemoveListener(LogListener *listener) | ||
| 162 | { | ||
| 163 | std::lock_guard<std::mutex> lk(m_listeners_lock); | ||
| 164 | m_listeners.erase(listener); | ||
| 165 | } | ||
| 166 | |||
| 167 | void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg) | ||
| 168 | { | ||
| 169 | std::lock_guard<std::mutex> lk(m_listeners_lock); | ||
| 170 | |||
| 171 | std::set<LogListener*>::const_iterator i; | ||
| 172 | for (i = m_listeners.begin(); i != m_listeners.end(); ++i) | ||
| 173 | { | ||
| 174 | (*i)->Log(level, msg); | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | FileLogListener::FileLogListener(const char *filename) | ||
| 179 | { | ||
| 180 | OpenFStream(m_logfile, filename, std::ios::app); | ||
| 181 | SetEnable(true); | ||
| 182 | } | ||
| 183 | |||
| 184 | void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) | ||
| 185 | { | ||
| 186 | if (!IsEnabled() || !IsValid()) | ||
| 187 | return; | ||
| 188 | |||
| 189 | std::lock_guard<std::mutex> lk(m_log_lock); | ||
| 190 | m_logfile << msg << std::flush; | ||
| 191 | } | ||
| 192 | |||
| 193 | void DebuggerLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) | ||
| 194 | { | ||
| 195 | #if _MSC_VER | ||
| 196 | ::OutputDebugStringA(msg); | ||
| 197 | #endif | ||
| 198 | } | ||