mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
52b3105f65
Summary: ## Overview This diff is an RFC to port a logging feature from iOS to Android. Changelog: [Internal] ## Motivation On iOS we have the following log functions and behaviors available for logging native warnings and errors: - **Warnings** (`RCTLogWarn`) - Log level 'warn' to console - Display warning in LogBox - **Errors** (`RCTLogError`) - Log level 'error' to console - Display a native RedBox (needs converted to show a LogBox if available) - **Logs** - We also have `RCTLog`, `RCTTrace`, `RCTAdvice`, `RCTInfo`, which just log to the console. In Java, we have: - **Warnings** - **None**, added in this diff - **Errors** (`DevSupportManager.showNewJavaError`) - Log level 'error' to console with `FLog.e` - Display a native RedBox (needs converted to show a LogBox if available - **Logs** - `ReactSoftException` (crashes the app??) - `ReactNoCrashSoftException` (only logs??) - Others? ## Details This diff adds a method to pair with `RCTLogWarn`, `DevSupportManager.showNewJavaWarning`, which will log to the console and show a LogBox warning if LogBox is available. ## Concerns I have a few concerns/questions about the state of logging on Android: - Should/can we move all of the logging to it's own class, like how RCTLog works? - Why does some logging happen on DevSupportManager and some in other classes? - If we moved it all to it's own class, how could we access the reactContext to call the RCTLog JS module Reviewed By: JoshuaGross Differential Revision: D20056394 fbshipit-source-id: 32d57e300685e46da8039fc77cb22b4084acf81a
27 lines
628 B
Java
27 lines
628 B
Java
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
package com.facebook.react.util;
|
|
|
|
import com.facebook.react.bridge.JavaScriptModule;
|
|
|
|
/**
|
|
* JS module interface for RCTLog
|
|
*
|
|
* <p>The RCTLog module allows for showing native logs in JavaScript.
|
|
*/
|
|
public interface RCTLog extends JavaScriptModule {
|
|
|
|
/**
|
|
* Send a log to JavaScript.
|
|
*
|
|
* @param level The level of the log.
|
|
* @param message The message to log.
|
|
*/
|
|
void logIfNoNativeHook(String level, String message);
|
|
}
|