Skip to content

Commit

Permalink
Actually define RCTSetLogThreshold()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jspahrsummers authored and facebook-github-bot-2 committed Sep 28, 2015
1 parent 92109b8 commit 0ff3a42
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions React/Base/RCTLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ - (void)logMessage:(NSString *)message level:(NSString *)level;
"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,
Expand Down

0 comments on commit 0ff3a42

Please sign in to comment.