Skip to content

Commit 8922315

Browse files
javacheFacebook Github Bot
authored andcommitted
Remove duplicate definition of nativeLoggingHook
Reviewed By: lexs Differential Revision: D4160267 fbshipit-source-id: 8e23ea355095f1f94610068010b7cdf385d69e40
1 parent 674d86c commit 8922315

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

ReactAndroid/src/main/jni/xreact/jni/JSLogging.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,18 @@ JSValueRef nativeLoggingHook(
1919
const JSValueRef arguments[], JSValueRef *exception) {
2020
android_LogPriority logLevel = ANDROID_LOG_DEBUG;
2121
if (argumentCount > 1) {
22-
int level = (int) JSValueToNumber(ctx, arguments[1], NULL);
22+
int level = (int)Value(ctx, arguments[1]).asNumber();
2323
// The lowest log level we get from JS is 0. We shift and cap it to be
2424
// in the range the Android logging method expects.
2525
logLevel = std::min(
2626
static_cast<android_LogPriority>(level + ANDROID_LOG_DEBUG),
2727
ANDROID_LOG_FATAL);
2828
}
2929
if (argumentCount > 0) {
30-
JSStringRef jsString = JSValueToStringCopy(ctx, arguments[0], NULL);
31-
String message = String::adopt(jsString);
30+
String message = Value(ctx, arguments[0]).toString();
3231
FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.str().c_str());
3332
}
34-
return JSValueMakeUndefined(ctx);
33+
return Value::makeUndefined(ctx);
3534
}
3635

3736
}};

ReactAndroid/src/main/jni/xreact/jni/JSLogging.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
namespace facebook {
88
namespace react {
9+
910
JSValueRef nativeLoggingHook(
1011
JSContextRef ctx,
1112
JSObjectRef function,
1213
JSObjectRef thisObject,
1314
size_t argumentCount,
1415
const JSValueRef arguments[], JSValueRef *exception);
16+
1517
}}

ReactAndroid/src/main/jni/xreact/jni/OnLoad.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ProxyExecutor.h"
1616
#include "WebWorkers.h"
1717
#include "JCallback.h"
18+
#include "JSLogging.h"
1819

1920
#ifdef WITH_INSPECTOR
2021
#include "JInspector.h"
@@ -63,29 +64,6 @@ static std::string getApplicationPersistentDir() {
6364
return getApplicationDir("getFilesDir");
6465
}
6566

66-
static JSValueRef nativeLoggingHook(
67-
JSContextRef ctx,
68-
JSObjectRef function,
69-
JSObjectRef thisObject,
70-
size_t argumentCount,
71-
const JSValueRef arguments[], JSValueRef *exception) {
72-
android_LogPriority logLevel = ANDROID_LOG_DEBUG;
73-
if (argumentCount > 1) {
74-
int level = (int) JSValueToNumber(ctx, arguments[1], NULL);
75-
// The lowest log level we get from JS is 0. We shift and cap it to be
76-
// in the range the Android logging method expects.
77-
logLevel = std::min(
78-
static_cast<android_LogPriority>(level + ANDROID_LOG_DEBUG),
79-
ANDROID_LOG_FATAL);
80-
}
81-
if (argumentCount > 0) {
82-
JSStringRef jsString = JSValueToStringCopy(ctx, arguments[0], NULL);
83-
String message = String::adopt(jsString);
84-
FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.str().c_str());
85-
}
86-
return JSValueMakeUndefined(ctx);
87-
}
88-
8967
static JSValueRef nativePerformanceNow(
9068
JSContextRef ctx,
9169
JSObjectRef function,
@@ -99,7 +77,7 @@ static JSValueRef nativePerformanceNow(
9977
struct timespec now;
10078
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
10179
int64_t nano = now.tv_sec * NANOSECONDS_IN_SECOND + now.tv_nsec;
102-
return JSValueMakeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND));
80+
return Value::makeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND));
10381
}
10482

10583
class JSCJavaScriptExecutorHolder : public HybridClass<JSCJavaScriptExecutorHolder,

0 commit comments

Comments
 (0)