Remove duplicate definition of nativeLoggingHook

Reviewed By: lexs

Differential Revision: D4160267

fbshipit-source-id: 8e23ea355095f1f94610068010b7cdf385d69e40
This commit is contained in:
Pieter De Baets 2016-11-18 06:25:27 -08:00 коммит произвёл Facebook Github Bot
Родитель 674d86cdcb
Коммит 892231545b
3 изменённых файлов: 7 добавлений и 28 удалений

Просмотреть файл

@ -19,7 +19,7 @@ JSValueRef nativeLoggingHook(
const JSValueRef arguments[], JSValueRef *exception) { const JSValueRef arguments[], JSValueRef *exception) {
android_LogPriority logLevel = ANDROID_LOG_DEBUG; android_LogPriority logLevel = ANDROID_LOG_DEBUG;
if (argumentCount > 1) { if (argumentCount > 1) {
int level = (int) JSValueToNumber(ctx, arguments[1], NULL); int level = (int)Value(ctx, arguments[1]).asNumber();
// The lowest log level we get from JS is 0. We shift and cap it to be // The lowest log level we get from JS is 0. We shift and cap it to be
// in the range the Android logging method expects. // in the range the Android logging method expects.
logLevel = std::min( logLevel = std::min(
@ -27,11 +27,10 @@ JSValueRef nativeLoggingHook(
ANDROID_LOG_FATAL); ANDROID_LOG_FATAL);
} }
if (argumentCount > 0) { if (argumentCount > 0) {
JSStringRef jsString = JSValueToStringCopy(ctx, arguments[0], NULL); String message = Value(ctx, arguments[0]).toString();
String message = String::adopt(jsString);
FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.str().c_str()); FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.str().c_str());
} }
return JSValueMakeUndefined(ctx); return Value::makeUndefined(ctx);
} }
}}; }};

Просмотреть файл

@ -6,10 +6,12 @@
namespace facebook { namespace facebook {
namespace react { namespace react {
JSValueRef nativeLoggingHook( JSValueRef nativeLoggingHook(
JSContextRef ctx, JSContextRef ctx,
JSObjectRef function, JSObjectRef function,
JSObjectRef thisObject, JSObjectRef thisObject,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], JSValueRef *exception); const JSValueRef arguments[], JSValueRef *exception);
}} }}

Просмотреть файл

@ -15,6 +15,7 @@
#include "ProxyExecutor.h" #include "ProxyExecutor.h"
#include "WebWorkers.h" #include "WebWorkers.h"
#include "JCallback.h" #include "JCallback.h"
#include "JSLogging.h"
#ifdef WITH_INSPECTOR #ifdef WITH_INSPECTOR
#include "JInspector.h" #include "JInspector.h"
@ -63,29 +64,6 @@ static std::string getApplicationPersistentDir() {
return getApplicationDir("getFilesDir"); return getApplicationDir("getFilesDir");
} }
static JSValueRef nativeLoggingHook(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef *exception) {
android_LogPriority logLevel = ANDROID_LOG_DEBUG;
if (argumentCount > 1) {
int level = (int) JSValueToNumber(ctx, arguments[1], NULL);
// The lowest log level we get from JS is 0. We shift and cap it to be
// in the range the Android logging method expects.
logLevel = std::min(
static_cast<android_LogPriority>(level + ANDROID_LOG_DEBUG),
ANDROID_LOG_FATAL);
}
if (argumentCount > 0) {
JSStringRef jsString = JSValueToStringCopy(ctx, arguments[0], NULL);
String message = String::adopt(jsString);
FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.str().c_str());
}
return JSValueMakeUndefined(ctx);
}
static JSValueRef nativePerformanceNow( static JSValueRef nativePerformanceNow(
JSContextRef ctx, JSContextRef ctx,
JSObjectRef function, JSObjectRef function,
@ -99,7 +77,7 @@ static JSValueRef nativePerformanceNow(
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC_RAW, &now); clock_gettime(CLOCK_MONOTONIC_RAW, &now);
int64_t nano = now.tv_sec * NANOSECONDS_IN_SECOND + now.tv_nsec; int64_t nano = now.tv_sec * NANOSECONDS_IN_SECOND + now.tv_nsec;
return JSValueMakeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND)); return Value::makeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND));
} }
class JSCJavaScriptExecutorHolder : public HybridClass<JSCJavaScriptExecutorHolder, class JSCJavaScriptExecutorHolder : public HybridClass<JSCJavaScriptExecutorHolder,