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