File tree Expand file tree Collapse file tree 4 files changed +52
-29
lines changed Expand file tree Collapse file tree 4 files changed +52
-29
lines changed Original file line number Diff line number Diff line change 1
1
load ("@fbsource//tools/build_defs/android:fb_android_library.bzl" , "fb_android_library" )
2
+ load ("@fbsource//tools/build_defs:fb_xplat_cxx_library.bzl" , "fb_xplat_cxx_library" )
2
3
3
4
oncall ("executorch" )
4
5
@@ -39,3 +40,14 @@ fb_android_library(
39
40
"//fbandroid/libraries/soloader/java/com/facebook/soloader/nativeloader:nativeloader" ,
40
41
],
41
42
)
43
+
44
+ fb_xplat_cxx_library (
45
+ name = "log_provider" ,
46
+ srcs = ["jni/log.cpp" ],
47
+ compiler_flags = [
48
+ "-frtti" ,
49
+ "-fexceptions" ,
50
+ "-Wno-unused-variable" ,
51
+ ],
52
+ visibility = ["PUBLIC" ],
53
+ )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ executorch_generated_lib(
25
25
26
26
fb_android_cxx_library (
27
27
name = "executorch_jni" ,
28
- srcs = ["jni_layer.cpp" ],
28
+ srcs = ["jni_layer.cpp" , "log.cpp" ],
29
29
headers = ["jni_layer_constants.h" ],
30
30
allow_jni_merging = False ,
31
31
compiler_flags = [
@@ -49,7 +49,7 @@ fb_android_cxx_library(
49
49
50
50
fb_android_cxx_library (
51
51
name = "executorch_jni_full" ,
52
- srcs = ["jni_layer.cpp" ],
52
+ srcs = ["jni_layer.cpp" , "log.cpp" ],
53
53
headers = ["jni_layer_constants.h" ],
54
54
allow_jni_merging = False ,
55
55
compiler_flags = [
Original file line number Diff line number Diff line change 33
33
#include < fbjni/ByteBuffer.h>
34
34
#include < fbjni/fbjni.h>
35
35
36
- #ifdef __ANDROID__
37
- #include < android/log.h>
38
-
39
- // For Android, write to logcat
40
- void et_pal_emit_log_message (
41
- et_timestamp_t timestamp,
42
- et_pal_log_level_t level,
43
- const char * filename,
44
- const char * function,
45
- size_t line,
46
- const char * message,
47
- size_t length) {
48
- int android_log_level = ANDROID_LOG_UNKNOWN;
49
- if (level == ' D' ) {
50
- android_log_level = ANDROID_LOG_DEBUG;
51
- } else if (level == ' I' ) {
52
- android_log_level = ANDROID_LOG_INFO;
53
- } else if (level == ' E' ) {
54
- android_log_level = ANDROID_LOG_ERROR;
55
- } else if (level == ' F' ) {
56
- android_log_level = ANDROID_LOG_FATAL;
57
- }
58
-
59
- __android_log_print (android_log_level, " ExecuTorch" , " %s" , message);
60
- }
61
- #endif
62
-
63
36
using namespace executorch ::extension;
64
37
using namespace torch ::executor;
65
38
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ #include < executorch/runtime/platform/log.h>
10
+ #include < executorch/runtime/platform/platform.h>
11
+ #include < executorch/runtime/platform/runtime.h>
12
+
13
+ #ifdef __ANDROID__
14
+ #include < android/log.h>
15
+
16
+ // For Android, write to logcat
17
+ void et_pal_emit_log_message (
18
+ et_timestamp_t timestamp,
19
+ et_pal_log_level_t level,
20
+ const char * filename,
21
+ const char * function,
22
+ size_t line,
23
+ const char * message,
24
+ size_t length) {
25
+ int android_log_level = ANDROID_LOG_UNKNOWN;
26
+ if (level == ' D' ) {
27
+ android_log_level = ANDROID_LOG_DEBUG;
28
+ } else if (level == ' I' ) {
29
+ android_log_level = ANDROID_LOG_INFO;
30
+ } else if (level == ' E' ) {
31
+ android_log_level = ANDROID_LOG_ERROR;
32
+ } else if (level == ' F' ) {
33
+ android_log_level = ANDROID_LOG_FATAL;
34
+ }
35
+
36
+ __android_log_print (android_log_level, " ExecuTorch" , " %s" , message);
37
+ }
38
+ #endif
You can’t perform that action at this time.
0 commit comments