Debian Codegraph @

src/ports/SkLog_android.cpp

raw
1 /*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "include/private/base/SkDebug.h"
9 #include "include/private/base/SkFeatures.h"
10 #include "include/private/base/SkLog.h"
11
12 #if defined(SK_BUILD_FOR_ANDROID)
13
14 #include <stdio.h>
15 #include <cstdarg>
16
17 #ifdef LOG_TAG
18 #undef LOG_TAG
19 #endif
20 #define LOG_TAG "skia"
21 #include <android/log.h>
22
23 // Print debug output to stdout as well. This is useful for command line
24 // applications
25 bool gSkDebugToStdOut = false;
26
27 void SkLogVAList(SkLogPriority priority, const char format[], va_list args) {
28 va_list args_copy;
29
30 if (gSkDebugToStdOut) {
31 va_copy(args_copy, args);
32 vprintf(format, args_copy);
33 va_end(args_copy);
34 fflush(stdout);
35 }
36
37 int android_priority = ANDROID_LOG_DEBUG;
38 switch (priority) {
39 case SkLogPriority::kFatal: android_priority = ANDROID_LOG_FATAL; break;
40 case SkLogPriority::kError: android_priority = ANDROID_LOG_ERROR; break;
41 case SkLogPriority::kWarning: android_priority = ANDROID_LOG_WARN; break;
42 case SkLogPriority::kDebug: android_priority = ANDROID_LOG_DEBUG; break;
43 default: android_priority = ANDROID_LOG_DEBUG; break;
44 }
45
46 // Forces all Render Engine logs to show as warnings. This hack should be dropped as we update
47 // SkDebugf call sites to have more precise priority.
48 #if defined(SK_IN_RENDERENGINE)
49 android_priority = ANDROID_LOG_WARN;
50 #endif
51
52 __android_log_vprint(android_priority, LOG_TAG, format, args);
53 }
54
55 #endif // defined(SK_BUILD_FOR_ANDROID)