Remove log level 'log' from JS
Summary: Log level 'log' from JS should be equivalent to 'info'. Also added knowledge of 'trace' log level in RCTLog. public Reviewed By: vjeux Differential Revision: D2615500 fb-gh-sync-id: 7a02f49bf7953c1a075741c21e984470c44b5551
This commit is contained in:
parent
824858c6b2
commit
d9b4c57e12
|
@ -29,6 +29,7 @@
|
|||
* own code.
|
||||
*/
|
||||
#define RCTLog(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__)
|
||||
#define RCTLogTrace(...) _RCTLog(RCTLogLevelTrace, __VA_ARGS__)
|
||||
#define RCTLogInfo(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__)
|
||||
#define RCTLogWarn(...) _RCTLog(RCTLogLevelWarning, __VA_ARGS__)
|
||||
#define RCTLogError(...) _RCTLog(RCTLogLevelError, __VA_ARGS__)
|
||||
|
@ -37,6 +38,7 @@
|
|||
* An enum representing the severity of the log message.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, RCTLogLevel) {
|
||||
RCTLogLevelTrace = 0,
|
||||
RCTLogLevelInfo = 1,
|
||||
RCTLogLevelWarning = 2,
|
||||
RCTLogLevelError = 3,
|
||||
|
|
|
@ -26,10 +26,11 @@
|
|||
static NSString *const RCTLogFunctionStack = @"RCTLogFunctionStack";
|
||||
|
||||
const char *RCTLogLevels[] = {
|
||||
"trace",
|
||||
"info",
|
||||
"warn",
|
||||
"error",
|
||||
"mustfix"
|
||||
"fatal",
|
||||
};
|
||||
|
||||
#if RCT_DEBUG
|
||||
|
@ -65,6 +66,9 @@ RCTLogFunction RCTDefaultLogFunction = ^(
|
|||
|
||||
int aslLevel;
|
||||
switch(level) {
|
||||
case RCTLogLevelTrace:
|
||||
aslLevel = ASL_LEVEL_DEBUG;
|
||||
break;
|
||||
case RCTLogLevelInfo:
|
||||
aslLevel = ASL_LEVEL_NOTICE;
|
||||
break;
|
||||
|
@ -210,9 +214,8 @@ void _RCTLogInternal(
|
|||
logFunction(level, fileName ? @(fileName) : nil, (lineNumber >= 0) ? @(lineNumber) : nil, message);
|
||||
}
|
||||
|
||||
#if RCT_DEBUG // Red box is only available in debug mode
|
||||
|
||||
// Log to red box
|
||||
#if RCT_DEBUG
|
||||
// Log to red box in debug mode.
|
||||
if ([UIApplication sharedApplication] && level >= RCTLOG_REDBOX_LEVEL) {
|
||||
NSArray<NSString *> *stackSymbols = [NSThread callStackSymbols];
|
||||
NSMutableArray<NSDictionary *> *stack =
|
||||
|
@ -238,9 +241,7 @@ void _RCTLogInternal(
|
|||
}
|
||||
|
||||
// Log to JS executor
|
||||
[[RCTBridge currentBridge] logMessage:message level:level ? @(RCTLogLevels[level - 1]) : @"info"];
|
||||
|
||||
[[RCTBridge currentBridge] logMessage:message level:level ? @(RCTLogLevels[level]) : @"info"];
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,10 +360,9 @@
|
|||
var OBJECT_COLUMN_NAME = '(index)';
|
||||
var LOG_LEVELS = {
|
||||
trace: 0,
|
||||
log: 1,
|
||||
info: 2,
|
||||
warn: 3,
|
||||
error: 4
|
||||
info: 1,
|
||||
warn: 2,
|
||||
error: 3
|
||||
};
|
||||
|
||||
function setupConsole(global) {
|
||||
|
@ -407,7 +406,7 @@
|
|||
}
|
||||
}
|
||||
if (rows.length === 0) {
|
||||
global.nativeLoggingHook('', LOG_LEVELS.log);
|
||||
global.nativeLoggingHook('', LOG_LEVELS.info);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -453,13 +452,13 @@
|
|||
// Native logging hook adds "RCTLog >" at the front of every
|
||||
// logged string, which would shift the header and screw up
|
||||
// the table
|
||||
global.nativeLoggingHook('\n' + table.join('\n'), LOG_LEVELS.log);
|
||||
global.nativeLoggingHook('\n' + table.join('\n'), LOG_LEVELS.info);
|
||||
}
|
||||
|
||||
global.console = {
|
||||
error: getNativeLogFunction(LOG_LEVELS.error),
|
||||
info: getNativeLogFunction(LOG_LEVELS.info),
|
||||
log: getNativeLogFunction(LOG_LEVELS.log),
|
||||
log: getNativeLogFunction(LOG_LEVELS.info),
|
||||
warn: getNativeLogFunction(LOG_LEVELS.warn),
|
||||
trace: getNativeLogFunction(LOG_LEVELS.trace),
|
||||
table: consoleTablePolyfill
|
||||
|
|
Loading…
Reference in New Issue