summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/common/logging_android.cc
blob: d660080d4c7251abd8b231e1252e3b0c012f2bec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2013 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 <android/log.h>
#include <iostream>
#include <sstream>

#include "gpu/command_buffer/common/logging.h"

namespace gpu {

namespace {
std::stringstream* g_log;
const char* kLogTag = "chromium-gpu";
}

std::ostream& Logger::stream() {
  if (!g_log)
    g_log = new std::stringstream();
  return *g_log;
}

Logger::~Logger() {
  if (!condition_) {
    __android_log_print(ANDROID_LOG_INFO, kLogTag, "%s", g_log->str().c_str());
    g_log->str(std::string());
    if (level_ == FATAL)
      assert(false);
  }
}

}  // namespace gpu