From 0faa4c363008c19e1527f7e21fc89a0b47a57eec Mon Sep 17 00:00:00 2001 From: parax0 <parax0@github.com> Date: Mon, 21 Mar 2016 15:29:56 -0600 Subject: [PATCH] Replaced uses of std::cout with Log::Write and Log::Error --- src/Core/OpenGL/CFramebuffer.cpp | 4 ++-- src/Core/OpenGL/CShader.cpp | 16 ++++++++-------- src/Core/Resource/CPakFile.cpp | 6 +++--- src/Core/Resource/Cooker/CTextureEncoder.cpp | 4 ++-- src/Core/Resource/Factory/CWorldLoader.cpp | 2 +- src/Core/Resource/Script/IPropertyTemplate.cpp | 2 +- src/Editor/main.cpp | 2 -- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/Core/OpenGL/CFramebuffer.cpp b/src/Core/OpenGL/CFramebuffer.cpp index 129bcd4d..185cb06e 100644 --- a/src/Core/OpenGL/CFramebuffer.cpp +++ b/src/Core/OpenGL/CFramebuffer.cpp @@ -1,5 +1,5 @@ #include "CFramebuffer.h" -#include <iostream> +#include <Common/Log.h> CFramebuffer::CFramebuffer() { @@ -58,7 +58,7 @@ void CFramebuffer::Init() mStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (mStatus != GL_FRAMEBUFFER_COMPLETE) - std::cout << "\rError: Framebuffer not complete\n"; + Log::Error("Framebuffer not complete"); mInitialized = true; } diff --git a/src/Core/OpenGL/CShader.cpp b/src/Core/OpenGL/CShader.cpp index 1e404f84..1915f33e 100644 --- a/src/Core/OpenGL/CShader.cpp +++ b/src/Core/OpenGL/CShader.cpp @@ -1,11 +1,11 @@ #include "CShader.h" #include "Core/Render/CGraphics.h" +#include <Common/Log.h> #include <Common/TString.h> #include <Common/types.h> #include <FileIO/CTextInStream.h> #include <fstream> -#include <iostream> #include <sstream> bool gDebugDumpShaders = false; @@ -54,7 +54,7 @@ bool CShader::CompileVertexSource(const char* kpSource) if (CompileStatus == GL_FALSE) { TString Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt"; - std::cout << "ERROR: Unable to compile vertex shader; dumped to " << Out << "\n"; + Log::Error("Unable to compile vertex shader; dumped to " + Out); DumpShaderSource(mVertexShader, Out); gFailedCompileCount++; @@ -66,7 +66,7 @@ bool CShader::CompileVertexSource(const char* kpSource) else if (gDebugDumpShaders == true) { TString Out = "dump/VS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt"; - std::cout << "Debug shader dumping enabled; dumped to " << Out << "\n"; + Log::Write("Debug shader dumping enabled; dumped to " + Out); DumpShaderSource(mVertexShader, Out); gSuccessfulCompileCount++; @@ -89,7 +89,7 @@ bool CShader::CompilePixelSource(const char* kpSource) if (CompileStatus == GL_FALSE) { TString Out = "dump/BadPS_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt"; - std::cout << "ERROR: Unable to compile pixel shader; dumped to " << Out << "\n"; + Log::Error("Unable to compile pixel shader; dumped to " + Out); DumpShaderSource(mPixelShader, Out); gFailedCompileCount++; @@ -101,7 +101,7 @@ bool CShader::CompilePixelSource(const char* kpSource) else if (gDebugDumpShaders == true) { TString Out = "dump/PS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt"; - std::cout << "Debug shader dumping enabled; dumped to " << Out << "\n"; + Log::Write("Debug shader dumping enabled; dumped to " + Out); DumpShaderSource(mPixelShader, Out); gSuccessfulCompileCount++; @@ -132,7 +132,7 @@ bool CShader::LinkShaders() if (LinkStatus == GL_FALSE) { TString Out = "dump/BadLink_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt"; - std::cout << "ERROR: Unable to link shaders. Dumped error log to " << Out << "\n"; + Log::Error("Unable to link shaders. Dumped error log to " + Out); GLint LogLen; glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &LogLen); @@ -205,9 +205,9 @@ CShader* CShader::FromResourceFile(const TString& ShaderName) CTextInStream PixelShaderFile(PixelShaderFilename.ToStdString()); if (!VertexShaderFile.IsValid()) - std::cout << "Error: Couldn't load vertex shader file for " << ShaderName << "\n"; + Log::Error("Couldn't load vertex shader file for " + ShaderName); if (!PixelShaderFile.IsValid()) - std::cout << "Error: Couldn't load pixel shader file for " << ShaderName << "\n"; + Log::Error("Error: Couldn't load pixel shader file for " + ShaderName); if ((!VertexShaderFile.IsValid()) || (!PixelShaderFile.IsValid())) return nullptr; std::stringstream VertexShader; diff --git a/src/Core/Resource/CPakFile.cpp b/src/Core/Resource/CPakFile.cpp index 7216cc33..215c1302 100644 --- a/src/Core/Resource/CPakFile.cpp +++ b/src/Core/Resource/CPakFile.cpp @@ -1,4 +1,5 @@ #include "CPakFile.h" +#include <Common/Log.h> #include <Common/types.h> #include <FileIO/CMemoryInStream.h> #include <FileIO/FileIO.h> @@ -97,7 +98,6 @@ std::vector<u8>* CPakFile::getResource(SResInfo& info) bool dcmp = decompress(cmp_buf.data(), cmp_buf.size(), res_buf->data(), res_buf->size()); if (!dcmp) { - std::cout << "Error: Unable to decompress " << info.resType.ToString() << " 0x" << std::hex << std::setw(8) << std::setfill('0') << info.resID << std::dec << "\n"; delete res_buf; return nullptr; } @@ -136,7 +136,7 @@ bool CPakFile::decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len) } if ((ret != Z_OK) && (ret != Z_STREAM_END)) { - std::cout << "zlib error: " << std::dec << ret << "\n"; + Log::Error("zlib error: " + TString::FromInt32(ret, 0, 10)); return false; } @@ -164,7 +164,7 @@ bool CPakFile::decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len) } if (ret != LZO_E_OK) { - std::cout << "LZO error: " << std::dec << ret << "\n"; + Log::Error("LZO error: " + TString::FromInt32(ret, 0, 10)); return false; } diff --git a/src/Core/Resource/Cooker/CTextureEncoder.cpp b/src/Core/Resource/Cooker/CTextureEncoder.cpp index 5e8819a1..a8332c5f 100644 --- a/src/Core/Resource/Cooker/CTextureEncoder.cpp +++ b/src/Core/Resource/Cooker/CTextureEncoder.cpp @@ -1,5 +1,5 @@ #include "CTextureEncoder.h" -#include <iostream> +#include <Common/Log.h> CTextureEncoder::CTextureEncoder() { @@ -62,7 +62,7 @@ void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex) { if (pTex->mTexelFormat != eDXT1) { - std::cout << "\rError: Unsupported texel format for decoding\n"; + Log::Error("Unsupported texel format for decoding"); return; } diff --git a/src/Core/Resource/Factory/CWorldLoader.cpp b/src/Core/Resource/Factory/CWorldLoader.cpp index 3bcf35d6..d0301867 100644 --- a/src/Core/Resource/Factory/CWorldLoader.cpp +++ b/src/Core/Resource/Factory/CWorldLoader.cpp @@ -138,7 +138,7 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& MLVL) } u32 NumCoordinates = MLVL.ReadLong(); - if (NumCoordinates != 4) std::cout << "\rError: Dock coordinate count not 4\n"; + if (NumCoordinates != 4) Log::Error("Dock coordinate count not 4"); for (u32 iCoord = 0; iCoord < NumCoordinates; iCoord++) pDock->DockCoordinates[iCoord] = CVector3f(MLVL); diff --git a/src/Core/Resource/Script/IPropertyTemplate.cpp b/src/Core/Resource/Script/IPropertyTemplate.cpp index 3dd62c2f..6b310f78 100644 --- a/src/Core/Resource/Script/IPropertyTemplate.cpp +++ b/src/Core/Resource/Script/IPropertyTemplate.cpp @@ -277,6 +277,6 @@ void CStructTemplate::DebugPrintProperties(TString base) tmp2->DebugPrintProperties(base); } else - std::cout << base << tmp->Name() << "\n"; + Log::Write(base + tmp->Name()); } } diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 9403f98f..420b4190 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -18,8 +18,6 @@ void QtLogRedirect(QtMsgType Type, const QMessageLogContext& /*rkContext*/, cons case QtCriticalMsg: Log::Write(TString("Qt Critical: ") + TO_TSTRING(rkMessage)); break; case QtFatalMsg: Log::Write(TString("Qt Fatal: ") + TO_TSTRING(rkMessage)); break; } - - std::cout << TO_TSTRING(rkMessage) << "\n"; } int main(int argc, char *argv[])