mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 08:26:23 +00:00
Add nativeLoggingHook to JSIExecutor
Reviewed By: danzimm Differential Revision: D7203114 fbshipit-source-id: 2f4640d19267dc4d75f6d6c8a7876c92abc22276
This commit is contained in:
parent
f5207ba9c7
commit
0150a0c85b
@ -8,6 +8,7 @@ EXPORTED_HEADERS = [
|
|||||||
"JavaModuleWrapper.h",
|
"JavaModuleWrapper.h",
|
||||||
"JavaScriptExecutorHolder.h",
|
"JavaScriptExecutorHolder.h",
|
||||||
"JSLoader.h",
|
"JSLoader.h",
|
||||||
|
"JSLogging.h",
|
||||||
"MethodInvoker.h",
|
"MethodInvoker.h",
|
||||||
"ModuleRegistryBuilder.h",
|
"ModuleRegistryBuilder.h",
|
||||||
"NativeArray.h",
|
"NativeArray.h",
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
#include "JSLogging.h"
|
#include "JSLogging.h"
|
||||||
|
|
||||||
#include <android/log.h>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <fb/log.h>
|
#include <fb/log.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <jschelpers/Value.h>
|
#include <jschelpers/Value.h>
|
||||||
|
|
||||||
@ -16,7 +15,8 @@ JSValueRef nativeLoggingHook(
|
|||||||
JSObjectRef function,
|
JSObjectRef function,
|
||||||
JSObjectRef thisObject,
|
JSObjectRef thisObject,
|
||||||
size_t argumentCount,
|
size_t argumentCount,
|
||||||
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)Value(ctx, arguments[1]).asNumber();
|
int level = (int)Value(ctx, arguments[1]).asNumber();
|
||||||
@ -28,9 +28,23 @@ JSValueRef nativeLoggingHook(
|
|||||||
}
|
}
|
||||||
if (argumentCount > 0) {
|
if (argumentCount > 0) {
|
||||||
String message = Value(ctx, arguments[0]).toString();
|
String message = Value(ctx, arguments[0]).toString();
|
||||||
FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.str().c_str());
|
reactAndroidLoggingHook(message.str(), logLevel);
|
||||||
}
|
}
|
||||||
return Value::makeUndefined(ctx);
|
return Value::makeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
}};
|
void reactAndroidLoggingHook(
|
||||||
|
const std::string& message,
|
||||||
|
android_LogPriority logLevel) {
|
||||||
|
FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void reactAndroidLoggingHook(
|
||||||
|
const std::string& message,
|
||||||
|
unsigned int logLevel) {
|
||||||
|
reactAndroidLoggingHook(
|
||||||
|
message, static_cast<android_LogPriority>(logLevel + ANDROID_LOG_DEBUG));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace react
|
||||||
|
} // namespace facebook
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <JavaScriptCore/JSContextRef.h>
|
#include <JavaScriptCore/JSContextRef.h>
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
@ -12,6 +15,15 @@ JSValueRef nativeLoggingHook(
|
|||||||
JSObjectRef function,
|
JSObjectRef function,
|
||||||
JSObjectRef thisObject,
|
JSObjectRef thisObject,
|
||||||
size_t argumentCount,
|
size_t argumentCount,
|
||||||
const JSValueRef arguments[], JSValueRef *exception);
|
const JSValueRef arguments[],
|
||||||
|
JSValueRef* exception);
|
||||||
|
|
||||||
}}
|
void reactAndroidLoggingHook(
|
||||||
|
const std::string& message,
|
||||||
|
android_LogPriority logLevel);
|
||||||
|
void reactAndroidLoggingHook(
|
||||||
|
const std::string& message,
|
||||||
|
unsigned int logLevel);
|
||||||
|
|
||||||
|
} // namespace react
|
||||||
|
} // namespace facebook
|
||||||
|
Loading…
x
Reference in New Issue
Block a user