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 11load ("@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" )
23
34oncall ("executorch" )
45
@@ -39,3 +40,14 @@ fb_android_library(
3940 "//fbandroid/libraries/soloader/java/com/facebook/soloader/nativeloader:nativeloader" ,
4041 ],
4142)
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(
2525
2626fb_android_cxx_library (
2727 name = "executorch_jni" ,
28- srcs = ["jni_layer.cpp" ],
28+ srcs = ["jni_layer.cpp" , "log.cpp" ],
2929 headers = ["jni_layer_constants.h" ],
3030 allow_jni_merging = False ,
3131 compiler_flags = [
@@ -49,7 +49,7 @@ fb_android_cxx_library(
4949
5050fb_android_cxx_library (
5151 name = "executorch_jni_full" ,
52- srcs = ["jni_layer.cpp" ],
52+ srcs = ["jni_layer.cpp" , "log.cpp" ],
5353 headers = ["jni_layer_constants.h" ],
5454 allow_jni_merging = False ,
5555 compiler_flags = [
Original file line number Diff line number Diff line change 3333#include < fbjni/ByteBuffer.h>
3434#include < fbjni/fbjni.h>
3535
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-
6336using namespace executorch ::extension;
6437using namespace torch ::executor;
6538
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