OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include <memory> |
| 12 |
| 13 #include "webrtc/rtc_base/logging.h" |
| 14 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
| 15 #include "webrtc/system_wrappers/include/logcat_trace_context.h" |
| 16 #include "webrtc/system_wrappers/include/trace.h" |
| 17 |
| 18 namespace webrtc_jni { |
| 19 |
| 20 JOW(void, Logging_nativeEnableTracing) |
| 21 (JNIEnv* jni, jclass, jstring j_path, jint nativeLevels) { |
| 22 std::string path = JavaToStdString(jni, j_path); |
| 23 if (nativeLevels != webrtc::kTraceNone) { |
| 24 webrtc::Trace::set_level_filter(nativeLevels); |
| 25 if (path != "logcat:") { |
| 26 RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false)) |
| 27 << "SetTraceFile failed"; |
| 28 } else { |
| 29 // Intentionally leak this to avoid needing to reason about its lifecycle. |
| 30 // It keeps no state and functions only as a dispatch point. |
| 31 static webrtc::LogcatTraceContext* g_trace_callback = |
| 32 new webrtc::LogcatTraceContext(); |
| 33 } |
| 34 } |
| 35 } |
| 36 |
| 37 JOW(void, Logging_nativeEnableLogToDebugOutput) |
| 38 (JNIEnv* jni, jclass, jint nativeSeverity) { |
| 39 if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_NONE) { |
| 40 rtc::LogMessage::LogToDebug( |
| 41 static_cast<rtc::LoggingSeverity>(nativeSeverity)); |
| 42 } |
| 43 } |
| 44 |
| 45 JOW(void, Logging_nativeEnableLogThreads)(JNIEnv* jni, jclass) { |
| 46 rtc::LogMessage::LogThreads(true); |
| 47 } |
| 48 |
| 49 JOW(void, Logging_nativeEnableLogTimeStamps)(JNIEnv* jni, jclass) { |
| 50 rtc::LogMessage::LogTimestamps(true); |
| 51 } |
| 52 |
| 53 JOW(void, Logging_nativeLog) |
| 54 (JNIEnv* jni, jclass, jint j_severity, jstring j_tag, jstring j_message) { |
| 55 std::string message = JavaToStdString(jni, j_message); |
| 56 std::string tag = JavaToStdString(jni, j_tag); |
| 57 LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag) << message; |
| 58 } |
| 59 |
| 60 } // namespace webrtc_jni |
OLD | NEW |