diff --git a/React/Base/RCTLog.h b/React/Base/RCTLog.h index 3d7670933..28a615af8 100644 --- a/React/Base/RCTLog.h +++ b/React/Base/RCTLog.h @@ -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, diff --git a/React/Base/RCTLog.m b/React/Base/RCTLog.m index b939bf8ad..d6bf84590 100644 --- a/React/Base/RCTLog.m +++ b/React/Base/RCTLog.m @@ -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 *stackSymbols = [NSThread callStackSymbols]; NSMutableArray *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 - } } diff --git a/packager/react-packager/src/Resolver/polyfills/console.js b/packager/react-packager/src/Resolver/polyfills/console.js index b6f20c761..e08e8ef7c 100644 --- a/packager/react-packager/src/Resolver/polyfills/console.js +++ b/packager/react-packager/src/Resolver/polyfills/console.js @@ -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