1 /*
2  *  Copyright 2018 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 #include "sdk/android/src/jni/logging/log_sink.h"
11 
12 #include "sdk/android/generated_logging_jni/JNILogging_jni.h"
13 
14 namespace webrtc {
15 namespace jni {
16 
JNILogSink(JNIEnv * env,const JavaRef<jobject> & j_logging)17 JNILogSink::JNILogSink(JNIEnv* env, const JavaRef<jobject>& j_logging)
18     : j_logging_(env, j_logging) {}
19 JNILogSink::~JNILogSink() = default;
20 
OnLogMessage(const std::string & msg,rtc::LoggingSeverity severity,const char * tag)21 void JNILogSink::OnLogMessage(const std::string& msg,
22                               rtc::LoggingSeverity severity,
23                               const char* tag) {
24   JNIEnv* env = AttachCurrentThreadIfNeeded();
25   Java_JNILogging_logToInjectable(env, j_logging_, NativeToJavaString(env, msg),
26                                   NativeToJavaInteger(env, severity),
27                                   NativeToJavaString(env, tag));
28 }
29 
OnLogMessage(const std::string & msg)30 void JNILogSink::OnLogMessage(const std::string& msg) {
31   RTC_NOTREACHED();
32 }
33 
34 }  // namespace jni
35 }  // namespace webrtc
36