Skip to content

Commit

Permalink
Report logs in dev to server on iOS
Browse files Browse the repository at this point in the history
Summary:
This diff adds server side logging for all log levels in development (some levels sampled)

There are two new mobile analytic event pipelines (that pipe to scuba table)

- rn_dev_logs ([pigeon](https://our.intern.facebook.com/intern/marauder/event/?name=rn_dev_logs) [scuba](https://fburl.com/scuba/pqxl6mf5))
- rn_dev_logs_sampled ([pigeon](https://our.intern.facebook.com/intern/marauder/event/?name=rn_dev_logs_sampled) [scuba](https://fburl.com/scuba/oqz6b5x3))

Notes:
- All React Native logs from JS and Native on iOS go through this path to be printed to the console, so everything will be caputured even though native errors/warnings do not necessarily show a red/yellow box
- All errors and warnings are logged
- Log level info is sampled

Reviewed By: sammy-SC

Differential Revision: D17789494

fbshipit-source-id: dea6359237dbd91f267949f5185a0c79bb4083b8
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Oct 7, 2019
1 parent 9cefc96 commit c71bbb0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions React/Base/RCTLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ RCT_EXTERN NSString *RCTFormatLog(
NSString *message
);

/**
* A method to generate a string RCTLogLevel
*/
RCT_EXTERN NSString *RCTFormatLogLevel(RCTLogLevel);

/**
* A method to generate a string from a RCTLogSource
*/
RCT_EXTERN NSString *RCTFormatLogSource(RCTLogSource);

/**
* The default logging function used by RCTLogXX.
*/
Expand Down
19 changes: 19 additions & 0 deletions React/Base/RCTLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix)
return log;
}

NSString *RCTFormatLogLevel(RCTLogLevel level)
{
NSDictionary *levelsToString = @{@(RCTLogLevelTrace) : @"trace",
@(RCTLogLevelInfo) : @"info",
@(RCTLogLevelWarning) : @"warning",
@(RCTLogLevelFatal) : @"fatal",
@(RCTLogLevelError) : @"error"};

return levelsToString[@(level)];
}

NSString *RCTFormatLogSource(RCTLogSource source)
{
NSDictionary *sourcesToString = @{@(RCTLogSourceNative) : @"native",
@(RCTLogSourceJavaScript) : @"js"};

return sourcesToString[@(source)];
}

static NSRegularExpression *nativeStackFrameRegex()
{
static dispatch_once_t onceToken;
Expand Down

0 comments on commit c71bbb0

Please sign in to comment.