[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:
Alex Kotliarskyi 2015-07-13 09:38:53 -07:00
parent 47315af069
commit d1b14ef062
1 changed files with 21 additions and 0 deletions

View File

@ -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)