Add Log.h to replace all uses of iostream

On Android iostream doesn't appear in logcat, the system log that's
often used for printf debugging. Introduce Chromium/ANGLE like logging
that looks like the following:

  InfoLog() << stuff << stuff;

This makes sure the message is put in logcat on Android and removes
static initializers from <iostream>

BUG=dawn:286

Change-Id: Ie0d018f49bcac1a7b740739a6e59d45ae6728638
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14102
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Turner <digit@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez
2019-12-05 11:13:01 +00:00
committed by Commit Bot service account
parent 1d6250d016
commit 95586ff184
13 changed files with 256 additions and 56 deletions

View File

@@ -15,12 +15,12 @@
#include "dawn_native/opengl/BackendGL.h"
#include "common/Constants.h"
#include "common/Log.h"
#include "dawn_native/Instance.h"
#include "dawn_native/OpenGLBackend.h"
#include "dawn_native/opengl/DeviceGL.h"
#include <cstring>
#include <iostream>
namespace dawn_native { namespace opengl {
@@ -102,11 +102,11 @@ namespace dawn_native { namespace opengl {
}
if (type == GL_DEBUG_TYPE_ERROR) {
std::cout << "OpenGL error:" << std::endl;
std::cout << " Source: " << sourceText << std::endl;
std::cout << " ID: " << id << std::endl;
std::cout << " Severity: " << severityText << std::endl;
std::cout << " Message: " << message << std::endl;
WarningLog() << "OpenGL error:"
<< "\n Source: " << sourceText //
<< "\n ID: " << id //
<< "\n Severity: " << severityText //
<< "\n Message: " << message;
// Abort on an error when in Debug mode.
UNREACHABLE();

View File

@@ -15,13 +15,13 @@
#include "dawn_native/opengl/PipelineGL.h"
#include "common/BitSetIterator.h"
#include "common/Log.h"
#include "dawn_native/BindGroupLayout.h"
#include "dawn_native/opengl/Forward.h"
#include "dawn_native/opengl/OpenGLFunctions.h"
#include "dawn_native/opengl/PipelineLayoutGL.h"
#include "dawn_native/opengl/ShaderModuleGL.h"
#include <iostream>
#include <set>
namespace dawn_native { namespace opengl {
@@ -64,9 +64,7 @@ namespace dawn_native { namespace opengl {
if (infoLogLength > 1) {
std::vector<char> buffer(infoLogLength);
gl.GetShaderInfoLog(shader, infoLogLength, nullptr, &buffer[0]);
std::cout << source << std::endl;
std::cout << "Program compilation failed:\n";
std::cout << buffer.data() << std::endl;
ErrorLog() << source << "\nProgram compilation failed:\n" << buffer.data();
}
}
return shader;
@@ -97,8 +95,7 @@ namespace dawn_native { namespace opengl {
if (infoLogLength > 1) {
std::vector<char> buffer(infoLogLength);
gl.GetProgramInfoLog(mProgram, infoLogLength, nullptr, &buffer[0]);
std::cout << "Program link failed:\n";
std::cout << buffer.data() << std::endl;
ErrorLog() << "Program link failed:\n" << buffer.data();
}
}