diff --git a/gpu/command_buffer/common/logging.cc b/gpu/command_buffer/common/logging.cc new file mode 100644 index 00000000000000..4bc35103008ec4 --- /dev/null +++ b/gpu/command_buffer/common/logging.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/common/logging.h" + +#include + +namespace gpu { + +std::ostream& Logger::stream() { + return std::cerr; +} + +Logger::~Logger() { + if (!condition_) { + std::cerr << std::endl; + std::cerr.flush(); + if (level_ == FATAL) + assert(false); + } +} + +} // namespace gpu diff --git a/gpu/command_buffer/common/logging.h b/gpu/command_buffer/common/logging.h index 6f8c99e5b0e8c5..47d0b4dca4dc05 100644 --- a/gpu/command_buffer/common/logging.h +++ b/gpu/command_buffer/common/logging.h @@ -7,7 +7,7 @@ #include -#include +#include // Windows defines an ERROR macro. #ifdef ERROR @@ -132,19 +132,17 @@ class Logger { << y_name << "(" << y << ")) failed. "; } - ~Logger() { - if (!condition_) { - std::cerr << std::endl; - std::cerr.flush(); - if (level_ == FATAL) - assert(false); - } - } + // Retrieves the stream that we write to. This header cannot depend on + // because that will add static initializers to all files that + // include this header. + std::ostream& stream(); + + ~Logger(); template Logger& operator<<(const T& value) { if (!condition_) - std::cerr << value; + stream() << value; return *this; } diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 6acbc8ae8d55e0..436545b497125e 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -59,6 +59,7 @@ 'command_buffer/common/gles2_cmd_utils.h', 'command_buffer/common/id_allocator.cc', 'command_buffer/common/id_allocator.h', + 'command_buffer/common/logging.cc', 'command_buffer/common/logging.h', 'command_buffer/common/thread_local.h', 'command_buffer/common/types.h', diff --git a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons index 4b7a433e83a3ad..ee1531b89f525b 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons +++ b/ppapi/native_client/src/shared/ppapi_proxy/nacl.scons @@ -88,6 +88,8 @@ command_buffer_common_srcs = [ 'command_buffer/common/cmd_buffer_common.cc', 'command_buffer/common/gles2_cmd_format.cc', 'command_buffer/common/gles2_cmd_utils.cc', + 'command_buffer/common/logging.cc', + 'command_buffer/common/logging.h', ] command_buffer_client_srcs = [