[React Native] Log to ASL
Summary: By default we were just writing all log messages to stderr. This also adds support for [Apple System Log](https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/asl_log.3.html) that can be viewed using standard tools.
This commit is contained in:
parent
47315af069
commit
d1b14ef062
|
@ -9,6 +9,8 @@
|
|||
|
||||
#import "RCTLog.h"
|
||||
|
||||
#include <asl.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTDefines.h"
|
||||
|
@ -57,6 +59,25 @@ RCTLogFunction RCTDefaultLogFunction = ^(
|
|||
);
|
||||
fprintf(stderr, "%s\n", log.UTF8String);
|
||||
fflush(stderr);
|
||||
|
||||
int aslLevel = ASL_LEVEL_ERR;
|
||||
switch(level) {
|
||||
case RCTLogLevelInfo:
|
||||
aslLevel = ASL_LEVEL_NOTICE;
|
||||
break;
|
||||
case RCTLogLevelWarning:
|
||||
aslLevel = ASL_LEVEL_WARNING;
|
||||
break;
|
||||
case RCTLogLevelError:
|
||||
aslLevel = ASL_LEVEL_ERR;
|
||||
break;
|
||||
case RCTLogLevelMustFix:
|
||||
aslLevel = ASL_LEVEL_EMERG;
|
||||
break;
|
||||
default:
|
||||
aslLevel = ASL_LEVEL_DEBUG;
|
||||
}
|
||||
asl_log(NULL, NULL, aslLevel, "%s", message.UTF8String);
|
||||
};
|
||||
|
||||
void RCTSetLogFunction(RCTLogFunction logFunction)
|
||||
|
|
Loading…
Reference in New Issue