mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Wrapped fopen/close/read/write functions inside a simple "IOFile" class. Reading, writing, and error checking became simpler in most cases. It should be near impossible to forget to close a file now that the destructor takes care of it. (I hope this fixes Issue 3635) I have tested the functionality of most things, but it is possible I broke something. :p
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7328 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -83,7 +83,7 @@ LogManager::LogManager()
|
||||
m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager");
|
||||
m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay");
|
||||
|
||||
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX));
|
||||
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
|
||||
m_consoleLog = new ConsoleListener();
|
||||
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
||||
@ -176,21 +176,16 @@ void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) {
|
||||
}
|
||||
}
|
||||
|
||||
FileLogListener::FileLogListener(std::string filename) {
|
||||
m_filename = filename;
|
||||
m_logfile = fopen(filename.c_str(), "a+");
|
||||
FileLogListener::FileLogListener(const char *filename)
|
||||
{
|
||||
m_logfile.open(filename, std::ios::app);
|
||||
setEnable(true);
|
||||
}
|
||||
|
||||
FileLogListener::~FileLogListener() {
|
||||
if (m_logfile)
|
||||
fclose(m_logfile);
|
||||
}
|
||||
|
||||
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) {
|
||||
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
||||
{
|
||||
if (!m_enable || !isValid())
|
||||
return;
|
||||
|
||||
fwrite(msg, strlen(msg) * sizeof(char), 1, m_logfile);
|
||||
fflush(m_logfile);
|
||||
m_logfile << msg << std::flush;
|
||||
}
|
||||
|
Reference in New Issue
Block a user