summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/break_points.cpp2
-rw-r--r--src/common/chunk_file.h35
-rw-r--r--src/common/file_util.cpp84
-rw-r--r--src/common/log.h16
-rw-r--r--src/common/mem_arena.cpp14
-rw-r--r--src/common/memory_util.cpp2
-rw-r--r--src/common/msg_handler.cpp2
-rw-r--r--src/common/string_util.cpp10
8 files changed, 94 insertions, 71 deletions
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
index 25528b864..587dbf40a 100644
--- a/src/common/break_points.cpp
+++ b/src/common/break_points.cpp
@@ -180,7 +180,7 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr,
180 { 180 {
181 if (Log) 181 if (Log)
182 { 182 {
183 INFO_LOG(MEMMAP, "CHK %08x (%s) %s%i %0*x at %08x (%s)", 183 LOG_DEBUG(Debug_Breakpoint, "CHK %08x (%s) %s%i %0*x at %08x (%s)",
184 pc, debug_interface->getDescription(pc).c_str(), 184 pc, debug_interface->getDescription(pc).c_str(),
185 write ? "Write" : "Read", size*8, size*2, iValue, addr, 185 write ? "Write" : "Read", size*8, size*2, iValue, addr,
186 debug_interface->getDescription(addr).c_str() 186 debug_interface->getDescription(addr).c_str()
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 32af74594..39a14dc81 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -154,7 +154,7 @@ public:
154 Do(foundVersion); 154 Do(foundVersion);
155 155
156 if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) { 156 if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) {
157 WARN_LOG(COMMON, "Savestate failure: wrong version %d found for %s", foundVersion, title); 157 LOG_ERROR(Common, "Savestate failure: wrong version %d found for %s", foundVersion, title);
158 SetError(ERROR_FAILURE); 158 SetError(ERROR_FAILURE);
159 return PointerWrapSection(*this, -1, title); 159 return PointerWrapSection(*this, -1, title);
160 } 160 }
@@ -178,7 +178,14 @@ public:
178 case MODE_READ: if (memcmp(data, *ptr, size) != 0) return false; break; 178 case MODE_READ: if (memcmp(data, *ptr, size) != 0) return false; break;
179 case MODE_WRITE: memcpy(*ptr, data, size); break; 179 case MODE_WRITE: memcpy(*ptr, data, size); break;
180 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything 180 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
181 case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; 181 case MODE_VERIFY:
182 for (int i = 0; i < size; i++) {
183 _dbg_assert_msg_(Common, ((u8*)data)[i] == (*ptr)[i],
184 "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n",
185 ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i],
186 (*ptr)[i], (*ptr)[i], &(*ptr)[i]);
187 }
188 break;
182 default: break; // throw an error? 189 default: break; // throw an error?
183 } 190 }
184 (*ptr) += size; 191 (*ptr) += size;
@@ -191,7 +198,14 @@ public:
191 case MODE_READ: memcpy(data, *ptr, size); break; 198 case MODE_READ: memcpy(data, *ptr, size); break;
192 case MODE_WRITE: memcpy(*ptr, data, size); break; 199 case MODE_WRITE: memcpy(*ptr, data, size); break;
193 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything 200 case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
194 case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break; 201 case MODE_VERIFY:
202 for (int i = 0; i < size; i++) {
203 _dbg_assert_msg_(Common, ((u8*)data)[i] == (*ptr)[i],
204 "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n",
205 ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i],
206 (*ptr)[i], (*ptr)[i], &(*ptr)[i]);
207 }
208 break;
195 default: break; // throw an error? 209 default: break; // throw an error?
196 } 210 }
197 (*ptr) += size; 211 (*ptr) += size;
@@ -476,7 +490,7 @@ public:
476 break; 490 break;
477 491
478 default: 492 default:
479 ERROR_LOG(COMMON, "Savestate error: invalid mode %d.", mode); 493 LOG_ERROR(Common, "Savestate error: invalid mode %d.", mode);
480 } 494 }
481 } 495 }
482 496
@@ -490,7 +504,12 @@ public:
490 case MODE_READ: x = (char*)*ptr; break; 504 case MODE_READ: x = (char*)*ptr; break;
491 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; 505 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
492 case MODE_MEASURE: break; 506 case MODE_MEASURE: break;
493 case MODE_VERIFY: _dbg_assert_msg_(COMMON, !strcmp(x.c_str(), (char*)*ptr), "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n", x.c_str(), (char*)*ptr, ptr); break; 507 case MODE_VERIFY:
508 _dbg_assert_msg_(Common,
509 !strcmp(x.c_str(), (char*)*ptr),
510 "Savestate verification failure: \"%s\" != \"%s\" (at %p).\n",
511 x.c_str(), (char*)*ptr, ptr);
512 break;
494 } 513 }
495 (*ptr) += stringLen; 514 (*ptr) += stringLen;
496 } 515 }
@@ -504,7 +523,11 @@ public:
504 case MODE_READ: x = (wchar_t*)*ptr; break; 523 case MODE_READ: x = (wchar_t*)*ptr; break;
505 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; 524 case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
506 case MODE_MEASURE: break; 525 case MODE_MEASURE: break;
507 case MODE_VERIFY: _dbg_assert_msg_(COMMON, x == (wchar_t*)*ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*ptr, ptr); break; 526 case MODE_VERIFY:
527 _dbg_assert_msg_(Common, x == (wchar_t*)*ptr,
528 "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n",
529 x.c_str(), (wchar_t*)*ptr, ptr);
530 break;
508 } 531 }
509 (*ptr) += stringLen; 532 (*ptr) += stringLen;
510 } 533 }
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 7579d8c0f..88c46c117 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -88,7 +88,7 @@ bool IsDirectory(const std::string &filename)
88#endif 88#endif
89 89
90 if (result < 0) { 90 if (result < 0) {
91 WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s", 91 LOG_WARNING(Common_Filesystem, "stat failed on %s: %s",
92 filename.c_str(), GetLastErrorMsg()); 92 filename.c_str(), GetLastErrorMsg());
93 return false; 93 return false;
94 } 94 }
@@ -100,33 +100,33 @@ bool IsDirectory(const std::string &filename)
100// Doesn't supports deleting a directory 100// Doesn't supports deleting a directory
101bool Delete(const std::string &filename) 101bool Delete(const std::string &filename)
102{ 102{
103 INFO_LOG(COMMON, "Delete: file %s", filename.c_str()); 103 LOG_INFO(Common_Filesystem, "file %s", filename.c_str());
104 104
105 // Return true because we care about the file no 105 // Return true because we care about the file no
106 // being there, not the actual delete. 106 // being there, not the actual delete.
107 if (!Exists(filename)) 107 if (!Exists(filename))
108 { 108 {
109 WARN_LOG(COMMON, "Delete: %s does not exist", filename.c_str()); 109 LOG_WARNING(Common_Filesystem, "%s does not exist", filename.c_str());
110 return true; 110 return true;
111 } 111 }
112 112
113 // We can't delete a directory 113 // We can't delete a directory
114 if (IsDirectory(filename)) 114 if (IsDirectory(filename))
115 { 115 {
116 WARN_LOG(COMMON, "Delete failed: %s is a directory", filename.c_str()); 116 LOG_ERROR(Common_Filesystem, "Failed: %s is a directory", filename.c_str());
117 return false; 117 return false;
118 } 118 }
119 119
120#ifdef _WIN32 120#ifdef _WIN32
121 if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) 121 if (!DeleteFile(Common::UTF8ToTStr(filename).c_str()))
122 { 122 {
123 WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", 123 LOG_ERROR(Common_Filesystem, "DeleteFile failed on %s: %s",
124 filename.c_str(), GetLastErrorMsg()); 124 filename.c_str(), GetLastErrorMsg());
125 return false; 125 return false;
126 } 126 }
127#else 127#else
128 if (unlink(filename.c_str()) == -1) { 128 if (unlink(filename.c_str()) == -1) {
129 WARN_LOG(COMMON, "Delete: unlink failed on %s: %s", 129 LOG_ERROR(Common_Filesystem, "unlink failed on %s: %s",
130 filename.c_str(), GetLastErrorMsg()); 130 filename.c_str(), GetLastErrorMsg());
131 return false; 131 return false;
132 } 132 }
@@ -138,17 +138,17 @@ bool Delete(const std::string &filename)
138// Returns true if successful, or path already exists. 138// Returns true if successful, or path already exists.
139bool CreateDir(const std::string &path) 139bool CreateDir(const std::string &path)
140{ 140{
141 INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); 141 LOG_TRACE(Common_Filesystem, "directory %s", path.c_str());
142#ifdef _WIN32 142#ifdef _WIN32
143 if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), nullptr)) 143 if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), nullptr))
144 return true; 144 return true;
145 DWORD error = GetLastError(); 145 DWORD error = GetLastError();
146 if (error == ERROR_ALREADY_EXISTS) 146 if (error == ERROR_ALREADY_EXISTS)
147 { 147 {
148 WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", path.c_str()); 148 LOG_WARNING(Common_Filesystem, "CreateDirectory failed on %s: already exists", path.c_str());
149 return true; 149 return true;
150 } 150 }
151 ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %i", path.c_str(), error); 151 LOG_ERROR(Common_Filesystem, "CreateDirectory failed on %s: %i", path.c_str(), error);
152 return false; 152 return false;
153#else 153#else
154 if (mkdir(path.c_str(), 0755) == 0) 154 if (mkdir(path.c_str(), 0755) == 0)
@@ -158,11 +158,11 @@ bool CreateDir(const std::string &path)
158 158
159 if (err == EEXIST) 159 if (err == EEXIST)
160 { 160 {
161 WARN_LOG(COMMON, "CreateDir: mkdir failed on %s: already exists", path.c_str()); 161 LOG_WARNING(Common_Filesystem, "mkdir failed on %s: already exists", path.c_str());
162 return true; 162 return true;
163 } 163 }
164 164
165 ERROR_LOG(COMMON, "CreateDir: mkdir failed on %s: %s", path.c_str(), strerror(err)); 165 LOG_ERROR(Common_Filesystem, "mkdir failed on %s: %s", path.c_str(), strerror(err));
166 return false; 166 return false;
167#endif 167#endif
168} 168}
@@ -171,11 +171,11 @@ bool CreateDir(const std::string &path)
171bool CreateFullPath(const std::string &fullPath) 171bool CreateFullPath(const std::string &fullPath)
172{ 172{
173 int panicCounter = 100; 173 int panicCounter = 100;
174 INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); 174 LOG_TRACE(Common_Filesystem, "path %s", fullPath.c_str());
175 175
176 if (FileUtil::Exists(fullPath)) 176 if (FileUtil::Exists(fullPath))
177 { 177 {
178 INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str()); 178 LOG_WARNING(Common_Filesystem, "path exists %s", fullPath.c_str());
179 return true; 179 return true;
180 } 180 }
181 181
@@ -192,7 +192,7 @@ bool CreateFullPath(const std::string &fullPath)
192 // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") 192 // Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
193 std::string const subPath(fullPath.substr(0, position + 1)); 193 std::string const subPath(fullPath.substr(0, position + 1));
194 if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { 194 if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) {
195 ERROR_LOG(COMMON, "CreateFullPath: directory creation failed"); 195 LOG_ERROR(Common, "CreateFullPath: directory creation failed");
196 return false; 196 return false;
197 } 197 }
198 198
@@ -200,7 +200,7 @@ bool CreateFullPath(const std::string &fullPath)
200 panicCounter--; 200 panicCounter--;
201 if (panicCounter <= 0) 201 if (panicCounter <= 0)
202 { 202 {
203 ERROR_LOG(COMMON, "CreateFullPath: directory structure is too deep"); 203 LOG_ERROR(Common, "CreateFullPath: directory structure is too deep");
204 return false; 204 return false;
205 } 205 }
206 position++; 206 position++;
@@ -211,12 +211,12 @@ bool CreateFullPath(const std::string &fullPath)
211// Deletes a directory filename, returns true on success 211// Deletes a directory filename, returns true on success
212bool DeleteDir(const std::string &filename) 212bool DeleteDir(const std::string &filename)
213{ 213{
214 INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str()); 214 LOG_INFO(Common_Filesystem, "directory %s", filename.c_str());
215 215
216 // check if a directory 216 // check if a directory
217 if (!FileUtil::IsDirectory(filename)) 217 if (!FileUtil::IsDirectory(filename))
218 { 218 {
219 ERROR_LOG(COMMON, "DeleteDir: Not a directory %s", filename.c_str()); 219 LOG_ERROR(Common_Filesystem, "Not a directory %s", filename.c_str());
220 return false; 220 return false;
221 } 221 }
222 222
@@ -227,7 +227,7 @@ bool DeleteDir(const std::string &filename)
227 if (rmdir(filename.c_str()) == 0) 227 if (rmdir(filename.c_str()) == 0)
228 return true; 228 return true;
229#endif 229#endif
230 ERROR_LOG(COMMON, "DeleteDir: %s: %s", filename.c_str(), GetLastErrorMsg()); 230 LOG_ERROR(Common_Filesystem, "failed %s: %s", filename.c_str(), GetLastErrorMsg());
231 231
232 return false; 232 return false;
233} 233}
@@ -235,11 +235,11 @@ bool DeleteDir(const std::string &filename)
235// renames file srcFilename to destFilename, returns true on success 235// renames file srcFilename to destFilename, returns true on success
236bool Rename(const std::string &srcFilename, const std::string &destFilename) 236bool Rename(const std::string &srcFilename, const std::string &destFilename)
237{ 237{
238 INFO_LOG(COMMON, "Rename: %s --> %s", 238 LOG_TRACE(Common_Filesystem, "%s --> %s",
239 srcFilename.c_str(), destFilename.c_str()); 239 srcFilename.c_str(), destFilename.c_str());
240 if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) 240 if (rename(srcFilename.c_str(), destFilename.c_str()) == 0)
241 return true; 241 return true;
242 ERROR_LOG(COMMON, "Rename: failed %s --> %s: %s", 242 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s",
243 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 243 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
244 return false; 244 return false;
245} 245}
@@ -247,13 +247,13 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
247// copies file srcFilename to destFilename, returns true on success 247// copies file srcFilename to destFilename, returns true on success
248bool Copy(const std::string &srcFilename, const std::string &destFilename) 248bool Copy(const std::string &srcFilename, const std::string &destFilename)
249{ 249{
250 INFO_LOG(COMMON, "Copy: %s --> %s", 250 LOG_TRACE(Common_Filesystem, "%s --> %s",
251 srcFilename.c_str(), destFilename.c_str()); 251 srcFilename.c_str(), destFilename.c_str());
252#ifdef _WIN32 252#ifdef _WIN32
253 if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) 253 if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE))
254 return true; 254 return true;
255 255
256 ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", 256 LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s",
257 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 257 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
258 return false; 258 return false;
259#else 259#else
@@ -267,7 +267,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
267 FILE *input = fopen(srcFilename.c_str(), "rb"); 267 FILE *input = fopen(srcFilename.c_str(), "rb");
268 if (!input) 268 if (!input)
269 { 269 {
270 ERROR_LOG(COMMON, "Copy: input failed %s --> %s: %s", 270 LOG_ERROR(Common_Filesystem, "opening input failed %s --> %s: %s",
271 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 271 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
272 return false; 272 return false;
273 } 273 }
@@ -277,7 +277,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
277 if (!output) 277 if (!output)
278 { 278 {
279 fclose(input); 279 fclose(input);
280 ERROR_LOG(COMMON, "Copy: output failed %s --> %s: %s", 280 LOG_ERROR(Common_Filesystem, "opening output failed %s --> %s: %s",
281 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 281 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
282 return false; 282 return false;
283 } 283 }
@@ -291,8 +291,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
291 { 291 {
292 if (ferror(input) != 0) 292 if (ferror(input) != 0)
293 { 293 {
294 ERROR_LOG(COMMON, 294 LOG_ERROR(Common_Filesystem,
295 "Copy: failed reading from source, %s --> %s: %s", 295 "failed reading from source, %s --> %s: %s",
296 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 296 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
297 goto bail; 297 goto bail;
298 } 298 }
@@ -302,8 +302,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
302 int wnum = fwrite(buffer, sizeof(char), rnum, output); 302 int wnum = fwrite(buffer, sizeof(char), rnum, output);
303 if (wnum != rnum) 303 if (wnum != rnum)
304 { 304 {
305 ERROR_LOG(COMMON, 305 LOG_ERROR(Common_Filesystem,
306 "Copy: failed writing to output, %s --> %s: %s", 306 "failed writing to output, %s --> %s: %s",
307 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); 307 srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
308 goto bail; 308 goto bail;
309 } 309 }
@@ -326,13 +326,13 @@ u64 GetSize(const std::string &filename)
326{ 326{
327 if (!Exists(filename)) 327 if (!Exists(filename))
328 { 328 {
329 WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.c_str()); 329 LOG_ERROR(Common_Filesystem, "failed %s: No such file", filename.c_str());
330 return 0; 330 return 0;
331 } 331 }
332 332
333 if (IsDirectory(filename)) 333 if (IsDirectory(filename))
334 { 334 {
335 WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str()); 335 LOG_ERROR(Common_Filesystem, "failed %s: is a directory", filename.c_str());
336 return 0; 336 return 0;
337 } 337 }
338 338
@@ -343,12 +343,12 @@ u64 GetSize(const std::string &filename)
343 if (stat64(filename.c_str(), &buf) == 0) 343 if (stat64(filename.c_str(), &buf) == 0)
344#endif 344#endif
345 { 345 {
346 DEBUG_LOG(COMMON, "GetSize: %s: %lld", 346 LOG_TRACE(Common_Filesystem, "%s: %lld",
347 filename.c_str(), (long long)buf.st_size); 347 filename.c_str(), (long long)buf.st_size);
348 return buf.st_size; 348 return buf.st_size;
349 } 349 }
350 350
351 ERROR_LOG(COMMON, "GetSize: Stat failed %s: %s", 351 LOG_ERROR(Common_Filesystem, "Stat failed %s: %s",
352 filename.c_str(), GetLastErrorMsg()); 352 filename.c_str(), GetLastErrorMsg());
353 return 0; 353 return 0;
354} 354}
@@ -358,7 +358,7 @@ u64 GetSize(const int fd)
358{ 358{
359 struct stat64 buf; 359 struct stat64 buf;
360 if (fstat64(fd, &buf) != 0) { 360 if (fstat64(fd, &buf) != 0) {
361 ERROR_LOG(COMMON, "GetSize: stat failed %i: %s", 361 LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s",
362 fd, GetLastErrorMsg()); 362 fd, GetLastErrorMsg());
363 return 0; 363 return 0;
364 } 364 }
@@ -371,13 +371,13 @@ u64 GetSize(FILE *f)
371 // can't use off_t here because it can be 32-bit 371 // can't use off_t here because it can be 32-bit
372 u64 pos = ftello(f); 372 u64 pos = ftello(f);
373 if (fseeko(f, 0, SEEK_END) != 0) { 373 if (fseeko(f, 0, SEEK_END) != 0) {
374 ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", 374 LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
375 f, GetLastErrorMsg()); 375 f, GetLastErrorMsg());
376 return 0; 376 return 0;
377 } 377 }
378 u64 size = ftello(f); 378 u64 size = ftello(f);
379 if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { 379 if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) {
380 ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", 380 LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
381 f, GetLastErrorMsg()); 381 f, GetLastErrorMsg());
382 return 0; 382 return 0;
383 } 383 }
@@ -387,11 +387,11 @@ u64 GetSize(FILE *f)
387// creates an empty file filename, returns true on success 387// creates an empty file filename, returns true on success
388bool CreateEmptyFile(const std::string &filename) 388bool CreateEmptyFile(const std::string &filename)
389{ 389{
390 INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str()); 390 LOG_TRACE(Common_Filesystem, "%s", filename.c_str());
391 391
392 if (!FileUtil::IOFile(filename, "wb")) 392 if (!FileUtil::IOFile(filename, "wb"))
393 { 393 {
394 ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s", 394 LOG_ERROR(Common_Filesystem, "failed %s: %s",
395 filename.c_str(), GetLastErrorMsg()); 395 filename.c_str(), GetLastErrorMsg());
396 return false; 396 return false;
397 } 397 }
@@ -404,7 +404,7 @@ bool CreateEmptyFile(const std::string &filename)
404// results into parentEntry. Returns the number of files+directories found 404// results into parentEntry. Returns the number of files+directories found
405u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) 405u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
406{ 406{
407 INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str()); 407 LOG_TRACE(Common_Filesystem, "directory %s", directory.c_str());
408 // How many files + directories we found 408 // How many files + directories we found
409 u32 foundEntries = 0; 409 u32 foundEntries = 0;
410#ifdef _WIN32 410#ifdef _WIN32
@@ -474,7 +474,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
474// Deletes the given directory and anything under it. Returns true on success. 474// Deletes the given directory and anything under it. Returns true on success.
475bool DeleteDirRecursively(const std::string &directory) 475bool DeleteDirRecursively(const std::string &directory)
476{ 476{
477 INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str()); 477 LOG_TRACE(Common_Filesystem, "%s", directory.c_str());
478#ifdef _WIN32 478#ifdef _WIN32
479 // Find the first file in the directory. 479 // Find the first file in the directory.
480 WIN32_FIND_DATA ffd; 480 WIN32_FIND_DATA ffd;
@@ -588,7 +588,7 @@ std::string GetCurrentDir()
588 // Get the current working directory (getcwd uses malloc) 588 // Get the current working directory (getcwd uses malloc)
589 if (!(dir = __getcwd(nullptr, 0))) { 589 if (!(dir = __getcwd(nullptr, 0))) {
590 590
591 ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", 591 LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s",
592 GetLastErrorMsg()); 592 GetLastErrorMsg());
593 return nullptr; 593 return nullptr;
594 } 594 }
@@ -647,7 +647,7 @@ std::string GetSysDirectory()
647#endif 647#endif
648 sysDir += DIR_SEP; 648 sysDir += DIR_SEP;
649 649
650 INFO_LOG(COMMON, "GetSysDirectory: Setting to %s:", sysDir.c_str()); 650 LOG_DEBUG(Common_Filesystem, "Setting to %s:", sysDir.c_str());
651 return sysDir; 651 return sysDir;
652} 652}
653 653
@@ -695,7 +695,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
695 { 695 {
696 if (!FileUtil::IsDirectory(newPath)) 696 if (!FileUtil::IsDirectory(newPath))
697 { 697 {
698 WARN_LOG(COMMON, "Invalid path specified %s", newPath.c_str()); 698 LOG_ERROR(Common_Filesystem, "Invalid path specified %s", newPath.c_str());
699 return paths[DirIDX]; 699 return paths[DirIDX];
700 } 700 }
701 else 701 else
diff --git a/src/common/log.h b/src/common/log.h
index 105db9802..c0f7ca2df 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -126,23 +126,23 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int
126//#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0) 126//#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0)
127//#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0) 127//#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0)
128 128
129#define OS_LOG(t,...) LOG_INFO(Common, __VA_ARGS__) 129//#define OS_LOG(t,...) LOG_INFO(Common, __VA_ARGS__)
130#define ERROR_LOG(t,...) LOG_ERROR(Common_Filesystem, __VA_ARGS__) 130//#define ERROR_LOG(t,...) LOG_ERROR(Common_Filesystem, __VA_ARGS__)
131#define WARN_LOG(t,...) LOG_WARNING(Kernel_SVC, __VA_ARGS__) 131//#define WARN_LOG(t,...) LOG_WARNING(Kernel_SVC, __VA_ARGS__)
132#define NOTICE_LOG(t,...) LOG_INFO(Service, __VA_ARGS__) 132//#define NOTICE_LOG(t,...) LOG_INFO(Service, __VA_ARGS__)
133#define INFO_LOG(t,...) LOG_INFO(Service_FS, __VA_ARGS__) 133//#define INFO_LOG(t,...) LOG_INFO(Service_FS, __VA_ARGS__)
134#define DEBUG_LOG(t,...) LOG_DEBUG(Common, __VA_ARGS__) 134//#define DEBUG_LOG(t,...) LOG_DEBUG(Common, __VA_ARGS__)
135 135
136#if MAX_LOGLEVEL >= DEBUG_LEVEL 136#if MAX_LOGLEVEL >= DEBUG_LEVEL
137#define _dbg_assert_(_t_, _a_) \ 137#define _dbg_assert_(_t_, _a_) \
138 if (!(_a_)) {\ 138 if (!(_a_)) {\
139 ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ 139 LOG_CRITICAL(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
140 __LINE__, __FILE__, __TIME__); \ 140 __LINE__, __FILE__, __TIME__); \
141 if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \ 141 if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \
142 } 142 }
143#define _dbg_assert_msg_(_t_, _a_, ...)\ 143#define _dbg_assert_msg_(_t_, _a_, ...)\
144 if (!(_a_)) {\ 144 if (!(_a_)) {\
145 ERROR_LOG(_t_, __VA_ARGS__); \ 145 LOG_CRITICAL(_t_, __VA_ARGS__); \
146 if (!PanicYesNo(__VA_ARGS__)) {Crash();} \ 146 if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
147 } 147 }
148#define _dbg_update_() Host_UpdateLogDisplay(); 148#define _dbg_update_() Host_UpdateLogDisplay();
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index 7d4fda0e2..9904d2472 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -71,7 +71,7 @@ int ashmem_create_region(const char *name, size_t size)
71 return fd; 71 return fd;
72 72
73error: 73error:
74 ERROR_LOG(MEMMAP, "NASTY ASHMEM ERROR: ret = %08x", ret); 74 LOG_ERROR(Common_Memory, "NASTY ASHMEM ERROR: ret = %08x", ret);
75 close(fd); 75 close(fd);
76 return ret; 76 return ret;
77} 77}
@@ -130,7 +130,7 @@ void MemArena::GrabLowMemSpace(size_t size)
130 // Note that it appears that ashmem is pinned by default, so no need to pin. 130 // Note that it appears that ashmem is pinned by default, so no need to pin.
131 if (fd < 0) 131 if (fd < 0)
132 { 132 {
133 ERROR_LOG(MEMMAP, "Failed to grab ashmem space of size: %08x errno: %d", (int)size, (int)(errno)); 133 LOG_ERROR(Common_Memory, "Failed to grab ashmem space of size: %08x errno: %d", (int)size, (int)(errno));
134 return; 134 return;
135 } 135 }
136#else 136#else
@@ -148,12 +148,12 @@ void MemArena::GrabLowMemSpace(size_t size)
148 } 148 }
149 else if (errno != EEXIST) 149 else if (errno != EEXIST)
150 { 150 {
151 ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno)); 151 LOG_ERROR(Common_Memory, "shm_open failed: %s", strerror(errno));
152 return; 152 return;
153 } 153 }
154 } 154 }
155 if (ftruncate(fd, size) < 0) 155 if (ftruncate(fd, size) < 0)
156 ERROR_LOG(MEMMAP, "Failed to allocate low memory space"); 156 LOG_ERROR(Common_Memory, "Failed to allocate low memory space");
157#endif 157#endif
158} 158}
159 159
@@ -197,7 +197,7 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base)
197 197
198 if (retval == MAP_FAILED) 198 if (retval == MAP_FAILED)
199 { 199 {
200 NOTICE_LOG(MEMMAP, "mmap failed"); 200 LOG_ERROR(Common_Memory, "mmap failed");
201 return nullptr; 201 return nullptr;
202 } 202 }
203 return retval; 203 return retval;
@@ -423,7 +423,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
423 base = (u8 *)base_addr; 423 base = (u8 *)base_addr;
424 if (Memory_TryBase(base, views, num_views, flags, arena)) 424 if (Memory_TryBase(base, views, num_views, flags, arena))
425 { 425 {
426 INFO_LOG(MEMMAP, "Found valid memory base at %p after %i tries.", base, base_attempts); 426 LOG_DEBUG(Common_Memory, "Found valid memory base at %p after %i tries.", base, base_attempts);
427 base_attempts = 0; 427 base_attempts = 0;
428 break; 428 break;
429 } 429 }
@@ -442,7 +442,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
442 u8 *base = MemArena::Find4GBBase(); 442 u8 *base = MemArena::Find4GBBase();
443 if (!Memory_TryBase(base, views, num_views, flags, arena)) 443 if (!Memory_TryBase(base, views, num_views, flags, arena))
444 { 444 {
445 ERROR_LOG(MEMMAP, "MemoryMap_Setup: Failed finding a memory base."); 445 LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base.");
446 PanicAlert("MemoryMap_Setup: Failed finding a memory base."); 446 PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
447 return 0; 447 return 0;
448 } 448 }
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index 93da5500b..ca8a2a9e4 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -109,7 +109,7 @@ void* AllocateAlignedMemory(size_t size,size_t alignment)
109 ptr = memalign(alignment, size); 109 ptr = memalign(alignment, size);
110#else 110#else
111 if (posix_memalign(&ptr, alignment, size) != 0) 111 if (posix_memalign(&ptr, alignment, size) != 0)
112 ERROR_LOG(MEMMAP, "Failed to allocate aligned memory"); 112 LOG_ERROR(Common_Memory, "Failed to allocate aligned memory");
113#endif 113#endif
114#endif 114#endif
115 115
diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp
index b3556aaa8..7ffedc45a 100644
--- a/src/common/msg_handler.cpp
+++ b/src/common/msg_handler.cpp
@@ -75,7 +75,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
75 Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); 75 Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args);
76 va_end(args); 76 va_end(args);
77 77
78 ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); 78 LOG_INFO(Common, "%s: %s", caption.c_str(), buffer);
79 79
80 // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored 80 // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored
81 if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL)) 81 if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL))
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 7a8274a91..6d9612fb5 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -107,7 +107,7 @@ std::string StringFromFormat(const char* format, ...)
107#else 107#else
108 va_start(args, format); 108 va_start(args, format);
109 if (vasprintf(&buf, format, args) < 0) 109 if (vasprintf(&buf, format, args) < 0)
110 ERROR_LOG(COMMON, "Unable to allocate memory for string"); 110 LOG_ERROR(Common, "Unable to allocate memory for string");
111 va_end(args); 111 va_end(args);
112 112
113 std::string temp = buf; 113 std::string temp = buf;
@@ -475,7 +475,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
475 iconv_t const conv_desc = iconv_open("UTF-8", fromcode); 475 iconv_t const conv_desc = iconv_open("UTF-8", fromcode);
476 if ((iconv_t)(-1) == conv_desc) 476 if ((iconv_t)(-1) == conv_desc)
477 { 477 {
478 ERROR_LOG(COMMON, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno)); 478 LOG_ERROR(Common, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno));
479 iconv_close(conv_desc); 479 iconv_close(conv_desc);
480 return {}; 480 return {};
481 } 481 }
@@ -510,7 +510,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
510 } 510 }
511 else 511 else
512 { 512 {
513 ERROR_LOG(COMMON, "iconv failure [%s]: %s", fromcode, strerror(errno)); 513 LOG_ERROR(Common, "iconv failure [%s]: %s", fromcode, strerror(errno));
514 break; 514 break;
515 } 515 }
516 } 516 }
@@ -531,7 +531,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
531 iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); 531 iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8");
532 if ((iconv_t)(-1) == conv_desc) 532 if ((iconv_t)(-1) == conv_desc)
533 { 533 {
534 ERROR_LOG(COMMON, "Iconv initialization failure [UTF-8]: %s", strerror(errno)); 534 LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: %s", strerror(errno));
535 iconv_close(conv_desc); 535 iconv_close(conv_desc);
536 return {}; 536 return {};
537 } 537 }
@@ -566,7 +566,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
566 } 566 }
567 else 567 else
568 { 568 {
569 ERROR_LOG(COMMON, "iconv failure [UTF-8]: %s", strerror(errno)); 569 LOG_ERROR(Common, "iconv failure [UTF-8]: %s", strerror(errno));
570 break; 570 break;
571 } 571 }
572 } 572 }