summaryrefslogtreecommitdiff
path: root/chromium/skia/ext/google_logging.cc
blob: 1d4eec9b213fd79e1d30919b201c01e49929a3ba (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
34
35
36
37
38
39
40
41
42
// Copyright (c) 2012 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.

// This file provides integration with Google-style "base/logging.h" assertions
// for Skia SkASSERT. If you don't want this, you can link with another file
// that provides integration with the logging of your choice.

#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "third_party/skia/include/core/SkTypes.h"

void SkDebugf_FileLine(const char* file, int line, const char* format, ...) {
  int severity = logging::LOG_INFO;
  if (severity < logging::GetMinLogLevel())
    return;

  va_list ap;
  va_start(ap, format);

  std::string msg;
  base::StringAppendV(&msg, format, ap);
  va_end(ap);

  logging::LogMessage(file, line, severity).stream() << msg;
}

void SkAbort_FileLine(const char* file, int line, const char* format, ...) {
  int severity = logging::LOG_FATAL;

  va_list ap;
  va_start(ap, format);

  std::string msg;
  base::StringAppendV(&msg, format, ap);
  va_end(ap);

  logging::LogMessage(file, line, severity).stream() << msg;
  sk_abort_no_print();
  // Extra safety abort().
  abort();
}