Actually define RCTSetLogThreshold()

Summary: This function was declared, but never defined, so calling it would crash your application.

I also took this opportunity to ensure that the logging threshold is given a default value upon initialization, not just the first time `RCTGetLogThreshold()` is called.

@​public

Reviewed By: @tadeuzagallo

Differential Revision: D2475622
This commit is contained in:
Justin Spahr-Summers 2015-09-28 04:20:20 -07:00 committed by facebook-github-bot-2
parent 92109b8a0c
commit 0ff3a421c9
1 changed files with 11 additions and 8 deletions

View File

@ -32,21 +32,24 @@ const char *RCTLogLevels[] = {
"mustfix"
};
#if RCT_DEBUG
static const RCTLogLevel RCTDefaultLogThreshold = RCTLogLevelInfo - 1;
#else
static const RCTLogLevel RCTDefaultLogThreshold = RCTLogLevelError;
#endif
static RCTLogFunction RCTCurrentLogFunction;
static RCTLogLevel RCTCurrentLogThreshold;
static RCTLogLevel RCTCurrentLogThreshold = RCTDefaultLogThreshold;
RCTLogLevel RCTGetLogThreshold()
{
if (!RCTCurrentLogThreshold) {
#if RCT_DEBUG
RCTCurrentLogThreshold = RCTLogLevelInfo - 1;
#else
RCTCurrentLogThreshold = RCTLogLevelError;
#endif
}
return RCTCurrentLogThreshold;
}
void RCTSetLogThreshold(RCTLogLevel threshold) {
RCTCurrentLogThreshold = threshold;
}
RCTLogFunction RCTDefaultLogFunction = ^(
RCTLogLevel level,
NSString *fileName,