diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index 031f51b119..19f8c67009 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -601,7 +601,7 @@ bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, std::string std::string outputISOFilename = g_Config.currentDirectory + "/" + fn.substr(nameOffset); size_t bytesCopied = 0; if (ExtractFile(z, isoFileIndex, outputISOFilename, &bytesCopied, allBytes)) { - ILOG("Successfully extracted ISO file to '%s'", outputISOFilename.c_str()); + INFO_LOG(IO, "Successfully extracted ISO file to '%s'", outputISOFilename.c_str()); } zip_close(z); if (deleteAfter) { diff --git a/ext/native/base/buffer.cpp b/ext/native/base/buffer.cpp index 2c28a09f7b..e603ff059f 100644 --- a/ext/native/base/buffer.cpp +++ b/ext/native/base/buffer.cpp @@ -18,10 +18,11 @@ #define MSG_NOSIGNAL 0x00 #endif -#include "base/logging.h" #include "base/timeutil.h" #include "file/fd_util.h" +#include "Common/Log.h" + Buffer::Buffer() { } Buffer::~Buffer() { } @@ -63,7 +64,7 @@ void Buffer::AppendValue(int value) { void Buffer::Take(size_t length, std::string *dest) { if (length > data_.size()) { - ELOG("Truncating length in Buffer::Take()"); + ERROR_LOG(IO, "Truncating length in Buffer::Take()"); length = data_.size(); } dest->resize(length); @@ -90,7 +91,7 @@ int Buffer::TakeLineCRLF(std::string *dest) { void Buffer::Skip(size_t length) { if (length > data_.size()) { - ELOG("Truncating length in Buffer::Skip()"); + ERROR_LOG(IO, "Truncating length in Buffer::Skip()"); length = data_.size(); } data_.erase(data_.begin(), data_.begin() + length); @@ -122,10 +123,10 @@ void Buffer::Printf(const char *fmt, ...) { ssize_t retval = vsnprintf(buffer, sizeof(buffer), fmt, vl); if (retval >= (ssize_t)sizeof(buffer)) { // Output was truncated. TODO: Do something. - ELOG("Buffer::Printf truncated output"); + ERROR_LOG(IO, "Buffer::Printf truncated output"); } if (retval < 0) { - ELOG("Buffer::Printf failed"); + ERROR_LOG(IO, "Buffer::Printf failed"); } va_end(vl); char *ptr = Append(retval); @@ -164,14 +165,14 @@ bool Buffer::FlushSocket(uintptr_t sock, double timeout, bool *cancelled) { if (!ready && leftTimeout >= 0.0) { leftTimeout -= CANCEL_INTERVAL; if (leftTimeout < 0) { - ELOG("FlushSocket timed out"); + ERROR_LOG(IO, "FlushSocket timed out"); return false; } } } int sent = send(sock, &data_[pos], (int)(end - pos), MSG_NOSIGNAL); if (sent < 0) { - ELOG("FlushSocket failed"); + ERROR_LOG(IO, "FlushSocket failed"); return false; } pos += sent; @@ -200,7 +201,7 @@ bool Buffer::ReadAll(int fd, int hintSize) { if (retval == 0) { break; } else if (retval < 0) { - ELOG("Error reading from buffer: %i", retval); + ERROR_LOG(IO, "Error reading from buffer: %i", retval); return false; } char *p = Append((size_t)retval); @@ -232,7 +233,7 @@ bool Buffer::ReadAllWithProgress(int fd, int knownSize, float *progress, bool *c if (retval == 0) { return true; } else if (retval < 0) { - ELOG("Error reading from buffer: %i", retval); + ERROR_LOG(IO, "Error reading from buffer: %i", retval); return false; } char *p = Append((size_t)retval); diff --git a/ext/native/base/buffer.h b/ext/native/base/buffer.h index 87018a3999..96abfbbd3f 100644 --- a/ext/native/base/buffer.h +++ b/ext/native/base/buffer.h @@ -1,11 +1,11 @@ -#ifndef _IO_BUFFER_H -#define _IO_BUFFER_H +#pragma once #include #include #include "base/basictypes.h" -#include "base/logging.h" + +#include "Common/Common.h" // Acts as a queue. Intended to be as fast as possible for most uses. // Does not do synchronization, must use external mutexes. @@ -84,5 +84,3 @@ class Buffer { DISALLOW_COPY_AND_ASSIGN(Buffer); }; - -#endif // _IO_BUFFER_H diff --git a/ext/native/base/stringutil.cpp b/ext/native/base/stringutil.cpp index 5fa467c577..ce2e1094fb 100644 --- a/ext/native/base/stringutil.cpp +++ b/ext/native/base/stringutil.cpp @@ -37,7 +37,7 @@ void OutputDebugStringUTF8(const char *p) { #else void OutputDebugStringUTF8(const char *p) { - ILOG("%s", p); + INFO_LOG(SYSTEM, "%s", p); } #endif diff --git a/ext/native/base/timeutil.cpp b/ext/native/base/timeutil.cpp index 5c70e80053..c2446c3989 100644 --- a/ext/native/base/timeutil.cpp +++ b/ext/native/base/timeutil.cpp @@ -1,7 +1,6 @@ #include #include "base/basictypes.h" -#include "base/logging.h" #include "base/timeutil.h" #ifdef _WIN32 @@ -15,6 +14,8 @@ #include #endif // HAVE_LIBNX +#include "Common/Log.h" + static double curtime = 0; static float curtime_f = 0; @@ -107,7 +108,7 @@ bool LoggingDeadline::End() { if (time_now_d() > endTime_) { double late = (time_now_d() - endTime_); double totalTime = late + totalTime_; - ELOG("===== %0.2fms DEADLINE PASSED FOR %s at %0.2fms - %0.2fms late =====", totalTime_ * 1000.0, name_, 1000.0 * totalTime, 1000.0 * late); + ERROR_LOG(SYSTEM, "===== %0.2fms DEADLINE PASSED FOR %s at %0.2fms - %0.2fms late =====", totalTime_ * 1000.0, name_, 1000.0 * totalTime, 1000.0 * late); return false; } return true; diff --git a/ext/native/file/path.cpp b/ext/native/file/path.cpp index 6aa562dbbc..2bcb7e1cdb 100644 --- a/ext/native/file/path.cpp +++ b/ext/native/file/path.cpp @@ -57,7 +57,7 @@ bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vectorvalue.toString(); - FLOG("String '%s' missing from node", child_name); + ERROR_LOG(IO, "String '%s' missing from node", child_name); return nullptr; } diff --git a/ext/native/json/json_reader.h b/ext/native/json/json_reader.h index a18915f488..472a19140d 100644 --- a/ext/native/json/json_reader.h +++ b/ext/native/json/json_reader.h @@ -2,9 +2,10 @@ #include #include "base/basictypes.h" -#include "base/logging.h" #include "ext/gason/gason.h" +#include "Common/Log.h" + namespace json { struct JsonGet { @@ -72,7 +73,7 @@ private: char *error_pos; int status = jsonParse(buffer_, &error_pos, &root_, alloc_); if (status != JSON_OK) { - ELOG("Error at (%i): %s\n%s\n\n", (int)(error_pos - buffer_), jsonStrError(status), error_pos); + ERROR_LOG(IO, "Error at (%i): %s\n%s\n\n", (int)(error_pos - buffer_), jsonStrError(status), error_pos); return false; } ok_ = true; diff --git a/ext/native/net/http_client.cpp b/ext/native/net/http_client.cpp index 29641aff77..7ff05ec99e 100644 --- a/ext/native/net/http_client.cpp +++ b/ext/native/net/http_client.cpp @@ -18,7 +18,6 @@ #include #include -#include "base/logging.h" #include "base/buffer.h" #include "base/stringutil.h" #include "data/compression.h" @@ -27,6 +26,8 @@ #include "net/url.h" #include "thread/threadutil.h" +#include "Common/Log.h" + namespace net { Connection::Connection() @@ -48,11 +49,11 @@ inline unsigned short myhtons(unsigned short x) { bool Connection::Resolve(const char *host, int port, DNSType type) { if ((intptr_t)sock_ != -1) { - ELOG("Resolve: Already have a socket"); + ERROR_LOG(IO, "Resolve: Already have a socket"); return false; } if (!host || port < 1 || port > 65535) { - ELOG("Resolve: Invalid host or port (%d)", port); + ERROR_LOG(IO, "Resolve: Invalid host or port (%d)", port); return false; } @@ -64,7 +65,7 @@ bool Connection::Resolve(const char *host, int port, DNSType type) { std::string err; if (!net::DNSResolve(host, port_str, &resolved_, err, type)) { - ELOG("Failed to resolve host %s: %s", host, err.c_str()); + ERROR_LOG(IO, "Failed to resolve host %s: %s", host, err.c_str()); // So that future calls fail. port_ = 0; return false; @@ -75,7 +76,7 @@ bool Connection::Resolve(const char *host, int port, DNSType type) { bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) { if (port_ <= 0) { - ELOG("Bad port"); + ERROR_LOG(IO, "Bad port"); return false; } sock_ = -1; @@ -91,7 +92,7 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) { int sock = socket(possible->ai_family, SOCK_STREAM, IPPROTO_TCP); if ((intptr_t)sock == -1) { - ELOG("Bad socket"); + ERROR_LOG(IO, "Bad socket"); continue; } fd_util::SetNonBlocking(sock, true); @@ -326,14 +327,14 @@ int Client::ReadResponseHeaders(Buffer *readbuf, std::vector &respo if (!ready && leftTimeout >= 0.0) { leftTimeout -= CANCEL_INTERVAL; if (leftTimeout < 0) { - ELOG("HTTP headers timed out"); + ERROR_LOG(IO, "HTTP headers timed out"); return -1; } } }; // Let's hope all the headers are available in a single packet... if (readbuf->Read(sock(), 4096) < 0) { - ELOG("Failed to read HTTP headers :("); + ERROR_LOG(IO, "Failed to read HTTP headers :("); return -1; } @@ -429,7 +430,7 @@ int Client::ReadResponseEntity(Buffer *readbuf, const std::vector & output->TakeAll(&compressed); bool result = decompress_string(compressed, &decompressed); if (!result) { - ELOG("Error decompressing using zlib"); + ERROR_LOG(IO, "Error decompressing using zlib"); if (progress) *progress = 0.0f; return -1; @@ -448,9 +449,7 @@ Download::Download(const std::string &url, const std::string &outfile) } Download::~Download() { - if (!joined_) { - FLOG("Download destructed without join"); - } + _assert_msg_(joined_, "Download destructed without join"); } void Download::Start() { @@ -459,7 +458,7 @@ void Download::Start() { void Download::Join() { if (joined_) { - ELOG("Already joined thread!"); + ERROR_LOG(IO, "Already joined thread!"); } thread_.join(); joined_ = true; @@ -479,7 +478,7 @@ int Download::PerformGET(const std::string &url) { http::Client client; if (!client.Resolve(fileUrl.Host().c_str(), fileUrl.Port())) { - ELOG("Failed resolving %s", url.c_str()); + ERROR_LOG(IO, "Failed resolving %s", url.c_str()); return -1; } @@ -488,7 +487,7 @@ int Download::PerformGET(const std::string &url) { } if (!client.Connect(2, 20.0, &cancelled_)) { - ELOG("Failed connecting to server or cancelled."); + ERROR_LOG(IO, "Failed connecting to server or cancelled."); return -1; } @@ -525,7 +524,7 @@ void Download::Do() { if (resultCode == 301 || resultCode == 302 || resultCode == 303 || resultCode == 307 || resultCode == 308) { std::string redirectURL = RedirectLocation(downloadURL); if (redirectURL.empty()) { - ELOG("Could not find Location header for redirect"); + ERROR_LOG(IO, "Could not find Location header for redirect"); resultCode_ = resultCode; } else if (redirectURL == downloadURL || redirectURL == url_) { // Simple loop detected, bail out. @@ -534,18 +533,18 @@ void Download::Do() { // Perform the next GET. if (resultCode_ == 0) - ILOG("Download of %s redirected to %s", downloadURL.c_str(), redirectURL.c_str()); + INFO_LOG(IO, "Download of %s redirected to %s", downloadURL.c_str(), redirectURL.c_str()); downloadURL = redirectURL; continue; } if (resultCode == 200) { - ILOG("Completed downloading %s to %s", url_.c_str(), outfile_.empty() ? "memory" : outfile_.c_str()); + INFO_LOG(IO, "Completed downloading %s to %s", url_.c_str(), outfile_.empty() ? "memory" : outfile_.c_str()); if (!outfile_.empty() && !buffer_.FlushToFile(outfile_.c_str())) { - ELOG("Failed writing download to %s", outfile_.c_str()); + ERROR_LOG(IO, "Failed writing download to %s", outfile_.c_str()); } } else { - ELOG("Error downloading %s to %s: %i", url_.c_str(), outfile_.c_str(), resultCode); + ERROR_LOG(IO, "Error downloading %s to %s: %i", url_.c_str(), outfile_.c_str(), resultCode); } resultCode_ = resultCode; } diff --git a/ext/native/net/http_headers.cpp b/ext/native/net/http_headers.cpp index fdfaa2c1ea..e568c7c5c8 100644 --- a/ext/native/net/http_headers.cpp +++ b/ext/native/net/http_headers.cpp @@ -4,11 +4,12 @@ #include #include -#include "base/logging.h" #include "base/stringutil.h" #include "file/fd_util.h" #include "net/sinks.h" +#include "Common/Log.h" + namespace http { RequestHeader::RequestHeader() @@ -32,7 +33,7 @@ bool RequestHeader::GetParamValue(const char *param_name, std::string *value) co for (size_t i = 0; i < v.size(); i++) { std::vector parts; SplitString(v[i], '=', parts); - ILOG("Param: %s Value: %s", parts[0].c_str(), parts[1].c_str()); + INFO_LOG(IO, "Param: %s Value: %s", parts[0].c_str(), parts[1].c_str()); if (parts[0] == param_name) { *value = parts[1]; return true; @@ -120,13 +121,13 @@ int RequestHeader::ParseHttpHeader(const char *buffer) { if (!strncasecmp(key, "User-Agent", key_len)) { user_agent = new char[value_len + 1]; memcpy(user_agent, buffer, value_len + 1); - ILOG("user-agent: %s", user_agent); + INFO_LOG(IO, "user-agent: %s", user_agent); } else if (!strncasecmp(key, "Referer", key_len)) { referer = new char[value_len + 1]; memcpy(referer, buffer, value_len + 1); } else if (!strncasecmp(key, "Content-Length", key_len)) { content_length = atoi(buffer); - ILOG("Content-Length: %i", (int)content_length); + INFO_LOG(IO, "Content-Length: %i", (int)content_length); } else { std::string key_str(key, key_len); std::transform(key_str.begin(), key_str.end(), key_str.begin(), tolower); @@ -149,12 +150,12 @@ void RequestHeader::ParseHeaders(net::InputSink *sink) { line_count++; if (type == SIMPLE) { // Done! - ILOG("Simple: Done parsing http request."); + INFO_LOG(IO, "Simple: Done parsing http request."); break; } } - ILOG("finished parsing request."); + INFO_LOG(IO, "finished parsing request."); ok = line_count > 1; } diff --git a/ext/native/net/http_server.cpp b/ext/native/net/http_server.cpp index c4120bae6a..1520b05873 100644 --- a/ext/native/net/http_server.cpp +++ b/ext/native/net/http_server.cpp @@ -34,13 +34,14 @@ #include #include -#include "base/logging.h" #include "base/buffer.h" #include "file/fd_util.h" #include "net/http_server.h" #include "net/sinks.h" #include "thread/executor.h" +#include "Common/Log.h" + namespace http { // Note: charset here helps prevent XSS. @@ -53,7 +54,7 @@ Request::Request(int fd) header_.ParseHeaders(in_); if (header_.ok) { - ILOG("The request carried with it %i bytes", (int)header_.content_length); + INFO_LOG(IO, "The request carried with it %i bytes", (int)header_.content_length); } else { Close(); } @@ -62,10 +63,10 @@ Request::Request(int fd) Request::~Request() { Close(); - CHECK(in_->Empty()); + _assert_(in_->Empty()); delete in_; if (!out_->Empty()) { - ELOG("Output not empty - connection abort?"); + ERROR_LOG(IO, "Output not empty - connection abort?"); } delete out_; } @@ -108,12 +109,12 @@ void Request::WriteHttpResponseHeader(const char *ver, int status, int64_t size, } void Request::WritePartial() const { - CHECK(fd_); + _assert_(fd_); out_->Flush(); } void Request::Write() { - CHECK(fd_); + _assert_(fd_); WritePartial(); Close(); } @@ -171,7 +172,7 @@ bool Server::Listen4(int port) { if (bind(listener_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { closesocket(listener_); - ELOG("Failed to bind to port %i. Bailing.", port); + ERROR_LOG(IO, "Failed to bind to port %d. Bailing.", port); return false; } @@ -188,7 +189,7 @@ bool Server::Listen4(int port) { port = ntohs(server_addr.sin_port); } - ILOG("HTTP server started on port %i", port); + INFO_LOG(IO, "HTTP server started on port %d", port); port_ = port; return true; @@ -216,7 +217,7 @@ bool Server::Listen6(int port, bool ipv6_only) { if (bind(listener_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { closesocket(listener_); - ELOG("Failed to bind to port %i. Bailing.", port); + ERROR_LOG(IO, "Failed to bind to port %d. Bailing.", port); return false; } @@ -233,7 +234,7 @@ bool Server::Listen6(int port, bool ipv6_only) { port = ntohs(server_addr.sin6_port); } - ILOG("HTTP server started on port %i", port); + INFO_LOG(IO, "HTTP server started on port %d", port); port_ = port; return true; @@ -268,7 +269,7 @@ bool Server::RunSlice(double timeout) { return true; } else { - ELOG("socket accept failed: %i", conn_fd); + ERROR_LOG(IO, "socket accept failed: %i", conn_fd); return false; } } @@ -293,7 +294,7 @@ void Server::Stop() { void Server::HandleConnection(int conn_fd) { Request request(conn_fd); if (!request.IsOK()) { - WLOG("Bad request, ignoring."); + WARN_LOG(IO, "Bad request, ignoring."); return; } HandleRequest(request); @@ -321,7 +322,7 @@ void Server::HandleRequestDefault(const Request &request) { } void Server::Handle404(const Request &request) { - ILOG("No handler for '%s', falling back to 404.", request.resource()); + INFO_LOG(IO, "No handler for '%s', falling back to 404.", request.resource()); const char *payload = "404 not found\r\n"; request.WriteHttpResponseHeader("1.0", 404, (int)strlen(payload)); request.Out()->Push(payload); diff --git a/ext/native/net/resolve.cpp b/ext/native/net/resolve.cpp index c4fc78fc62..e1479541a5 100644 --- a/ext/native/net/resolve.cpp +++ b/ext/native/net/resolve.cpp @@ -1,6 +1,5 @@ +#include "ppsspp_config.h" #include "net/resolve.h" -#include "base/logging.h" -#include "base/timeutil.h" #include #include @@ -25,6 +24,7 @@ #include #endif +#include "base/timeutil.h" namespace net { @@ -45,6 +45,7 @@ void Shutdown() } bool DNSResolve(const std::string &host, const std::string &service, addrinfo **res, std::string &error, DNSType type) { + #if PPSSPP_PLATFORM(SWITCH) // Force IPv4 lookups. if (type == DNSType::IPV6) { @@ -102,7 +103,7 @@ void DNSResolveFree(addrinfo *res) freeaddrinfo(res); } -bool GetIPList(std::vector& IP4s) { +bool GetIPList(std::vector &IP4s) { char ipstr[INET6_ADDRSTRLEN]; // We use IPv6 length since it's longer than IPv4 #if defined(getifaddrs) // On Android: Requires __ANDROID_API__ >= 24 struct ifaddrs* ifAddrStruct = NULL; diff --git a/ext/native/net/sinks.cpp b/ext/native/net/sinks.cpp index d9bf32d9d0..8c4434b31d 100644 --- a/ext/native/net/sinks.cpp +++ b/ext/native/net/sinks.cpp @@ -1,4 +1,6 @@ -#ifdef _WIN32 +#include "ppsspp_config.h" + +#if PPSSPP_PLATFORM(WINDOWS) #ifndef NOMINMAX #define NOMINMAX @@ -21,10 +23,11 @@ #include #include -#include "base/logging.h" #include "net/sinks.h" #include "file/fd_util.h" +#include "Common/Log.h" + #ifndef MSG_NOSIGNAL // Default value to 0x00 (do nothing) in systems where it's not supported #define MSG_NOSIGNAL 0 @@ -182,7 +185,7 @@ bool InputSink::Block() { void InputSink::AccountFill(int bytes) { if (bytes < 0) { - ELOG("Error reading from socket"); + ERROR_LOG(IO, "Error reading from socket"); return; } @@ -303,10 +306,10 @@ bool OutputSink::Printf(const char *fmt, ...) { // Okay, did we actually write? if (result >= (int)avail) { // This means the result string was too big for the buffer. - ELOG("Not enough space to format output."); + ERROR_LOG(IO, "Not enough space to format output."); return false; } else if (result < 0) { - ELOG("vsnprintf failed."); + ERROR_LOG(IO, "vsnprintf failed."); return false; } @@ -373,7 +376,7 @@ void OutputSink::AccountPush(size_t bytes) { void OutputSink::AccountDrain(int bytes) { if (bytes < 0) { - ELOG("Error writing to socket"); + ERROR_LOG(IO, "Error writing to socket"); return; } diff --git a/ext/native/net/url.cpp b/ext/native/net/url.cpp index 45175372e7..943ed4e3eb 100644 --- a/ext/native/net/url.cpp +++ b/ext/native/net/url.cpp @@ -1,7 +1,8 @@ -#include "base/logging.h" #include "base/stringutil.h" #include "net/url.h" +#include "Common/Log.h" + const char *UrlEncoder::unreservedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"; const char *UrlEncoder::hexChars = "0123456789ABCDEF"; @@ -10,7 +11,7 @@ int MultipartFormDataEncoder::seq = 0; void Url::Split() { size_t colonSlashSlash = url_.find("://"); if (colonSlashSlash == std::string::npos) { - ELOG("Invalid URL: %s", url_.c_str()); + ERROR_LOG(IO, "Invalid URL: %s", url_.c_str()); return; } diff --git a/ext/native/profiler/profiler.cpp b/ext/native/profiler/profiler.cpp index bf037a9510..2c2457812f 100644 --- a/ext/native/profiler/profiler.cpp +++ b/ext/native/profiler/profiler.cpp @@ -8,12 +8,13 @@ #include -#include "base/logging.h" #include "base/timeutil.h" #include "gfx_es2/draw_buffer.h" #include "ppsspp_config.h" #include "profiler/profiler.h" +#include "Common/Log.h" + #define MAX_CATEGORIES 64 // Can be any number, represents max profiled names. #define MAX_DEPTH 16 // Can be any number, represents max nesting depth of profiled names. #if PPSSPP_PLATFORM(IOS) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0 @@ -147,7 +148,7 @@ int internal_profiler_enter(const char *category_name, int *out_thread_id) { } internal_profiler_resume(thread_id, category, now); } else { - DLOG("profiler: recursive enter (%i - %s)", category, category_name); + DEBUG_LOG(SYSTEM, "profiler: recursive enter (%i - %s)", category, category_name); } depth++; @@ -164,7 +165,7 @@ void internal_profiler_leave(int thread_id, int category) { int &depth = profiler.depth[thread_id]; if (category < 0 || category >= MAX_CATEGORIES) { - ELOG("Bad category index %d", category); + ERROR_LOG(SYSTEM, "Bad category index %d", category); depth--; return; } @@ -172,9 +173,7 @@ void internal_profiler_leave(int thread_id, int category) { double now = real_time_now(); depth--; - if (depth < 0) { - FLOG("Profiler enter/leave mismatch!"); - } + _assert_msg_(depth >= 0, "Profiler enter/leave mismatch!"); int parent = profiler.parentCategory[thread_id][depth]; // When there's recursion, we don't suspend or resume. diff --git a/ext/native/thin3d/DataFormatGL.cpp b/ext/native/thin3d/DataFormatGL.cpp index b3a8092abf..5037586691 100644 --- a/ext/native/thin3d/DataFormatGL.cpp +++ b/ext/native/thin3d/DataFormatGL.cpp @@ -1,5 +1,4 @@ #include "thin3d/DataFormatGL.h" -#include "base/logging.h" #include "Common/Log.h" namespace Draw { diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index a8ae366eda..72ca079602 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -1,10 +1,7 @@ #include -#include "Common/MemoryUtil.h" -#include "Core/Reporting.h" -#include "GLQueueRunner.h" -#include "GLRenderManager.h" -#include "DataFormatGL.h" -#include "base/logging.h" + +#include "base/logging.h" // For OutputDebugStringUTF8 + #include "base/stringutil.h" #include "gfx/gl_common.h" #include "gfx/gl_debug_log.h" @@ -13,6 +10,14 @@ #include "math/dataconv.h" #include "math/math_util.h" +#include "Common/Log.h" +#include "Common/MemoryUtil.h" + +#include "Core/Reporting.h" +#include "GLQueueRunner.h" +#include "GLRenderManager.h" +#include "DataFormatGL.h" + #define TEXCACHE_NAME_CACHE_SIZE 16 #ifdef IOS @@ -223,7 +228,7 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski if (!anyFailed) Reporting::ReportMessage("Error in shader program link: info: %s\nfs: %s\n%s\nvs: %s\n%s", infoLog.c_str(), fsDesc.c_str(), fsCode, vsDesc.c_str(), vsCode); - ELOG("Could not link program:\n %s", infoLog.c_str()); + ERROR_LOG(G3D, "Could not link program:\n %s", infoLog.c_str()); ERROR_LOG(G3D, "VS desc:\n%s", vsDesc.c_str()); ERROR_LOG(G3D, "FS desc:\n%s", fsDesc.c_str()); ERROR_LOG(G3D, "VS:\n%s\n", vsCode); @@ -277,8 +282,8 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski if (!success) { std::string infoLog = GetInfoLog(shader, glGetShaderiv, glGetShaderInfoLog); #ifdef __ANDROID__ - ELOG("Error in shader compilation! %s\n", infoLog.c_str()); - ELOG("Shader source:\n%s\n", (const char *)code); + ERROR_LOG(G3D, "Error in shader compilation! %s\n", infoLog.c_str()); + ERROR_LOG(G3D, "Shader source:\n%s\n", (const char *)code); #endif ERROR_LOG(G3D, "Error in shader compilation for: %s", step.create_shader.shader->desc.c_str()); ERROR_LOG(G3D, "Info log: %s", infoLog.c_str()); @@ -547,10 +552,10 @@ retry_depth: // ILOG("Framebuffer verified complete."); break; case GL_FRAMEBUFFER_UNSUPPORTED: - ELOG("GL_FRAMEBUFFER_UNSUPPORTED"); + ERROR_LOG(G3D, "GL_FRAMEBUFFER_UNSUPPORTED"); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - ELOG("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); + ERROR_LOG(G3D, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); break; default: FLOG("Other framebuffer error: %i", status); @@ -1566,10 +1571,10 @@ void GLQueueRunner::fbo_ext_create(const GLRInitStep &step) { // ILOG("Framebuffer verified complete."); break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - ELOG("GL_FRAMEBUFFER_UNSUPPORTED"); + ERROR_LOG(G3D, "GL_FRAMEBUFFER_UNSUPPORTED"); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - ELOG("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT "); + ERROR_LOG(G3D, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT "); break; default: FLOG("Other framebuffer error: %i", status); diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index f21f67aac0..7345e84fa1 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -4,11 +4,12 @@ #include "gfx_es2/gpu_features.h" #include "thin3d/thin3d.h" #include "thread/threadutil.h" -#include "base/logging.h" + +#include "Common/Log.h" #include "Common/MemoryUtil.h" #if 0 // def _DEBUG -#define VLOG ILOG +#define VLOG(...) INFO_LOG(G3D, __VA_ARGS__) #else #define VLOG(...) #endif diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index 385d8a580e..4756b4bd09 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -4,14 +4,13 @@ #include #include "Common/Log.h" -#include "base/logging.h" #include "Common/Vulkan/VulkanContext.h" #include "thin3d/VulkanRenderManager.h" #include "thread/threadutil.h" #if 0 // def _DEBUG -#define VLOG ILOG +#define VLOG(...) INFO_LOG(G3D, __VA_ARGS__) #else #define VLOG(...) #endif @@ -162,7 +161,7 @@ void VulkanRenderManager::CreateBackbuffers() { VkImage *swapchainImages = new VkImage[swapchainImageCount_]; res = vkGetSwapchainImagesKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), &swapchainImageCount_, swapchainImages); if (res != VK_SUCCESS) { - ELOG("vkGetSwapchainImagesKHR failed"); + ERROR_LOG(G3D, "vkGetSwapchainImagesKHR failed"); delete[] swapchainImages; return; } @@ -210,7 +209,7 @@ void VulkanRenderManager::CreateBackbuffers() { } if (newInflightFrames_ != -1) { - ILOG("Updating inflight frames to %d", newInflightFrames_); + INFO_LOG(G3D, "Updating inflight frames to %d", newInflightFrames_); vulkan_->UpdateInflightFrames(newInflightFrames_); newInflightFrames_ = -1; } @@ -222,7 +221,7 @@ void VulkanRenderManager::CreateBackbuffers() { run_ = true; // Won't necessarily be 0. threadInitFrame_ = vulkan_->GetCurFrame(); - ILOG("Starting Vulkan submission thread (threadInitFrame_ = %d)", vulkan_->GetCurFrame()); + INFO_LOG(G3D, "Starting Vulkan submission thread (threadInitFrame_ = %d)", vulkan_->GetCurFrame()); thread_ = std::thread(&VulkanRenderManager::ThreadFunc, this); } } @@ -245,7 +244,7 @@ void VulkanRenderManager::StopThread() { frameData.profile.timestampDescriptions.clear(); } thread_.join(); - ILOG("Vulkan submission thread joined. Frame=%d", vulkan_->GetCurFrame()); + INFO_LOG(G3D, "Vulkan submission thread joined. Frame=%d", vulkan_->GetCurFrame()); // Eat whatever has been queued up for this frame if anything. Wipe(); @@ -275,7 +274,7 @@ void VulkanRenderManager::StopThread() { } } } else { - ILOG("Vulkan submission thread was already stopped."); + INFO_LOG(G3D, "Vulkan submission thread was already stopped."); } } @@ -300,7 +299,7 @@ void VulkanRenderManager::DestroyBackbuffers() { } VulkanRenderManager::~VulkanRenderManager() { - ILOG("VulkanRenderManager destructor"); + INFO_LOG(G3D, "VulkanRenderManager destructor"); StopThread(); vulkan_->WaitUntilQueueIdle(); @@ -352,7 +351,7 @@ void VulkanRenderManager::ThreadFunc() { } VLOG("PULL: Running frame %d", threadFrame); if (firstFrame) { - ILOG("Running first frame (%d)", threadFrame); + INFO_LOG(G3D, "Running first frame (%d)", threadFrame); firstFrame = false; } Run(threadFrame); @@ -428,7 +427,7 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling) { // Must be after the fence - this performs deletes. VLOG("PUSH: BeginFrame %d", curFrame); if (!run_) { - WLOG("BeginFrame while !run_!"); + WARN_LOG(G3D, "BeginFrame while !run_!"); } vulkan_->BeginFrame(); @@ -614,7 +613,7 @@ bool VulkanRenderManager::CopyFramebufferToMemorySync(VKRFramebuffer *src, VkIma } else { // Backbuffer. if (!(vulkan_->GetSurfaceCapabilities().supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT)) { - ELOG("Copying from backbuffer not supported, can't take screenshots"); + ERROR_LOG(G3D, "Copying from backbuffer not supported, can't take screenshots"); return false; } switch (vulkan_->GetSwapchainFormat()) { @@ -622,7 +621,7 @@ bool VulkanRenderManager::CopyFramebufferToMemorySync(VKRFramebuffer *src, VkIma case VK_FORMAT_R8G8B8A8_UNORM: srcFormat = Draw::DataFormat::R8G8B8A8_UNORM; break; // NOTE: If you add supported formats here, make sure to also support them in VulkanQueueRunner::CopyReadbackBuffer. default: - ELOG("Unsupported backbuffer format for screenshots"); + ERROR_LOG(G3D, "Unsupported backbuffer format for screenshots"); return false; } } @@ -1074,9 +1073,9 @@ void VulkanRenderManager::BeginSubmitFrame(int frame) { VkResult res = vkAcquireNextImageKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), UINT64_MAX, acquireSemaphore_, (VkFence)VK_NULL_HANDLE, &frameData.curSwapchainImage); if (res == VK_SUBOPTIMAL_KHR) { // Hopefully the resize will happen shortly. Ignore - one frame might look bad or something. - WLOG("VK_SUBOPTIMAL_KHR returned - ignoring"); + WARN_LOG(G3D, "VK_SUBOPTIMAL_KHR returned - ignoring"); } else if (res == VK_ERROR_OUT_OF_DATE_KHR) { - WLOG("VK_ERROR_OUT_OF_DATE_KHR returned - processing the frame, but not presenting"); + WARN_LOG(G3D, "VK_ERROR_OUT_OF_DATE_KHR returned - processing the frame, but not presenting"); frameData.skipSwap = true; } else { _assert_msg_(res == VK_SUCCESS, "vkAcquireNextImageKHR failed! result=%s", VulkanResultToString(res)); diff --git a/ext/native/thin3d/d3dx9_loader.cpp b/ext/native/thin3d/d3dx9_loader.cpp index f269ecbe04..e67f4b6ae8 100644 --- a/ext/native/thin3d/d3dx9_loader.cpp +++ b/ext/native/thin3d/d3dx9_loader.cpp @@ -6,9 +6,10 @@ #include #include -#include "base/logging.h" #include "thin3d/d3dx9_loader.h" +#include "Common/Log.h" + // TODO: See if we can use the bundled D3Dcompiler_47.dll to compiler for DX9 as well. typedef BOOL(__stdcall *TFunc_D3DXCheckVersion)(UINT D3DSDKVersion, UINT D3DXSDKVersion); @@ -114,7 +115,7 @@ HMODULE loadDllLastVersion(unsigned int* version, bool debugVersion) { } void handleNotFoundAddr(const char* sFuncName) { - ELOG("Failed to find D3DX function %s", sFuncName); + ERROR_LOG(G3D, "Failed to find D3DX function %s", sFuncName); failedFunctions++; } @@ -126,7 +127,7 @@ int LoadD3DX9Dynamic(bool debugVersion) { hm_d3dx = loadDllLastVersion(&d3dx_version, debugVersion); if (!hm_d3dx) { - ELOG("Failed to find D3DX dll."); + ERROR_LOG(G3D, "Failed to find D3DX dll."); return 0; } const int NERROR = -1; @@ -137,7 +138,7 @@ int LoadD3DX9Dynamic(bool debugVersion) { __HANDLE_DLL_ENTRY(D3DXCompileShader); if (failedFunctions > 0) { - ELOG("Failed to load %i D3DX functions. This will not go well.", failedFunctions); + ERROR_LOG(G3D, "Failed to load %i D3DX functions. This will not go well.", failedFunctions); } return failedFunctions > 0 ? 0 : d3dx_version;