summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/LogManager.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2011-03-11 10:21:46 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2011-03-11 10:21:46 +0000
commit59fd1008ca9cf4e9f75fdd6ee8ec53a2c7d7a13b (patch)
tree1de127fb452967ccc052324d9aff0775ea1b76cf /Source/Core/Common/Src/LogManager.cpp
parent4f69672b2b31581746aae907e7757981fc48db77 (diff)
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
Diffstat (limited to 'Source/Core/Common/Src/LogManager.cpp')
-rw-r--r--Source/Core/Common/Src/LogManager.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp
index 6c47b78d15..7e2275c4b1 100644
--- a/Source/Core/Common/Src/LogManager.cpp
+++ b/Source/Core/Common/Src/LogManager.cpp
@@ -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;
}