Skip to content

Commit d9b4c57

Browse files
javachefacebook-github-bot-5
authored andcommitted
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
1 parent 824858c commit d9b4c57

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

React/Base/RCTLog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* own code.
3030
*/
3131
#define RCTLog(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__)
32+
#define RCTLogTrace(...) _RCTLog(RCTLogLevelTrace, __VA_ARGS__)
3233
#define RCTLogInfo(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__)
3334
#define RCTLogWarn(...) _RCTLog(RCTLogLevelWarning, __VA_ARGS__)
3435
#define RCTLogError(...) _RCTLog(RCTLogLevelError, __VA_ARGS__)
@@ -37,6 +38,7 @@
3738
* An enum representing the severity of the log message.
3839
*/
3940
typedef NS_ENUM(NSInteger, RCTLogLevel) {
41+
RCTLogLevelTrace = 0,
4042
RCTLogLevelInfo = 1,
4143
RCTLogLevelWarning = 2,
4244
RCTLogLevelError = 3,

React/Base/RCTLog.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ - (void)logMessage:(NSString *)message level:(NSString *)level;
2626
static NSString *const RCTLogFunctionStack = @"RCTLogFunctionStack";
2727

2828
const char *RCTLogLevels[] = {
29+
"trace",
2930
"info",
3031
"warn",
3132
"error",
32-
"mustfix"
33+
"fatal",
3334
};
3435

3536
#if RCT_DEBUG
@@ -65,6 +66,9 @@ void RCTSetLogThreshold(RCTLogLevel threshold) {
6566

6667
int aslLevel;
6768
switch(level) {
69+
case RCTLogLevelTrace:
70+
aslLevel = ASL_LEVEL_DEBUG;
71+
break;
6872
case RCTLogLevelInfo:
6973
aslLevel = ASL_LEVEL_NOTICE;
7074
break;
@@ -210,9 +214,8 @@ void _RCTLogInternal(
210214
logFunction(level, fileName ? @(fileName) : nil, (lineNumber >= 0) ? @(lineNumber) : nil, message);
211215
}
212216

213-
#if RCT_DEBUG // Red box is only available in debug mode
214-
215-
// Log to red box
217+
#if RCT_DEBUG
218+
// Log to red box in debug mode.
216219
if ([UIApplication sharedApplication] && level >= RCTLOG_REDBOX_LEVEL) {
217220
NSArray<NSString *> *stackSymbols = [NSThread callStackSymbols];
218221
NSMutableArray<NSDictionary *> *stack =
@@ -238,9 +241,7 @@ void _RCTLogInternal(
238241
}
239242

240243
// Log to JS executor
241-
[[RCTBridge currentBridge] logMessage:message level:level ? @(RCTLogLevels[level - 1]) : @"info"];
242-
244+
[[RCTBridge currentBridge] logMessage:message level:level ? @(RCTLogLevels[level]) : @"info"];
243245
#endif
244-
245246
}
246247
}

packager/react-packager/src/Resolver/polyfills/console.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,9 @@
360360
var OBJECT_COLUMN_NAME = '(index)';
361361
var LOG_LEVELS = {
362362
trace: 0,
363-
log: 1,
364-
info: 2,
365-
warn: 3,
366-
error: 4
363+
info: 1,
364+
warn: 2,
365+
error: 3
367366
};
368367

369368
function setupConsole(global) {
@@ -407,7 +406,7 @@
407406
}
408407
}
409408
if (rows.length === 0) {
410-
global.nativeLoggingHook('', LOG_LEVELS.log);
409+
global.nativeLoggingHook('', LOG_LEVELS.info);
411410
return;
412411
}
413412

@@ -453,13 +452,13 @@
453452
// Native logging hook adds "RCTLog >" at the front of every
454453
// logged string, which would shift the header and screw up
455454
// the table
456-
global.nativeLoggingHook('\n' + table.join('\n'), LOG_LEVELS.log);
455+
global.nativeLoggingHook('\n' + table.join('\n'), LOG_LEVELS.info);
457456
}
458457

459458
global.console = {
460459
error: getNativeLogFunction(LOG_LEVELS.error),
461460
info: getNativeLogFunction(LOG_LEVELS.info),
462-
log: getNativeLogFunction(LOG_LEVELS.log),
461+
log: getNativeLogFunction(LOG_LEVELS.info),
463462
warn: getNativeLogFunction(LOG_LEVELS.warn),
464463
trace: getNativeLogFunction(LOG_LEVELS.trace),
465464
table: consoleTablePolyfill

0 commit comments

Comments
 (0)