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 "rtc_base/logging.h"
14 #include "sdk/android/native_api/jni/java_types.h"
15 #include "sdk/android/src/jni/jni_helpers.h"
16 
17 namespace webrtc {
18 namespace jni {
19 
JNI_FUNCTION_DECLARATION(void,Logging_nativeEnableLogToDebugOutput,JNIEnv * jni,jclass,jint nativeSeverity)20 JNI_FUNCTION_DECLARATION(void,
21                          Logging_nativeEnableLogToDebugOutput,
22                          JNIEnv* jni,
23                          jclass,
24                          jint nativeSeverity) {
25   if (nativeSeverity >= rtc::LS_VERBOSE && nativeSeverity <= rtc::LS_NONE) {
26     rtc::LogMessage::LogToDebug(
27         static_cast<rtc::LoggingSeverity>(nativeSeverity));
28   }
29 }
30 
JNI_FUNCTION_DECLARATION(void,Logging_nativeEnableLogThreads,JNIEnv * jni,jclass)31 JNI_FUNCTION_DECLARATION(void,
32                          Logging_nativeEnableLogThreads,
33                          JNIEnv* jni,
34                          jclass) {
35   rtc::LogMessage::LogThreads(true);
36 }
37 
JNI_FUNCTION_DECLARATION(void,Logging_nativeEnableLogTimeStamps,JNIEnv * jni,jclass)38 JNI_FUNCTION_DECLARATION(void,
39                          Logging_nativeEnableLogTimeStamps,
40                          JNIEnv* jni,
41                          jclass) {
42   rtc::LogMessage::LogTimestamps(true);
43 }
44 
JNI_FUNCTION_DECLARATION(void,Logging_nativeLog,JNIEnv * jni,jclass,jint j_severity,jstring j_tag,jstring j_message)45 JNI_FUNCTION_DECLARATION(void,
46                          Logging_nativeLog,
47                          JNIEnv* jni,
48                          jclass,
49                          jint j_severity,
50                          jstring j_tag,
51                          jstring j_message) {
52   std::string message = JavaToStdString(jni, JavaParamRef<jstring>(j_message));
53   std::string tag = JavaToStdString(jni, JavaParamRef<jstring>(j_tag));
54   RTC_LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag.c_str())
55       << message;
56 }
57 
58 }  // namespace jni
59 }  // namespace webrtc
60