From d1b14ef0627dc04847500faa7fef75fd3c22c900 Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Mon, 13 Jul 2015 09:38:53 -0700 Subject: [PATCH] [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. --- React/Base/RCTLog.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/React/Base/RCTLog.m b/React/Base/RCTLog.m index e34502f3b..25ad49e85 100644 --- a/React/Base/RCTLog.m +++ b/React/Base/RCTLog.m @@ -9,6 +9,8 @@ #import "RCTLog.h" +#include + #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)