Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit 0ff3a42

Browse files
jspahrsummersfacebook-github-bot-2
authored and
facebook-github-bot-2
committed
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
1 parent 92109b8 commit 0ff3a42

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

React/Base/RCTLog.m

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,24 @@ - (void)logMessage:(NSString *)message level:(NSString *)level;
3232
"mustfix"
3333
};
3434

35+
#if RCT_DEBUG
36+
static const RCTLogLevel RCTDefaultLogThreshold = RCTLogLevelInfo - 1;
37+
#else
38+
static const RCTLogLevel RCTDefaultLogThreshold = RCTLogLevelError;
39+
#endif
40+
3541
static RCTLogFunction RCTCurrentLogFunction;
36-
static RCTLogLevel RCTCurrentLogThreshold;
42+
static RCTLogLevel RCTCurrentLogThreshold = RCTDefaultLogThreshold;
3743

3844
RCTLogLevel RCTGetLogThreshold()
3945
{
40-
if (!RCTCurrentLogThreshold) {
41-
#if RCT_DEBUG
42-
RCTCurrentLogThreshold = RCTLogLevelInfo - 1;
43-
#else
44-
RCTCurrentLogThreshold = RCTLogLevelError;
45-
#endif
46-
}
4746
return RCTCurrentLogThreshold;
4847
}
4948

49+
void RCTSetLogThreshold(RCTLogLevel threshold) {
50+
RCTCurrentLogThreshold = threshold;
51+
}
52+
5053
RCTLogFunction RCTDefaultLogFunction = ^(
5154
RCTLogLevel level,
5255
NSString *fileName,

0 commit comments

Comments
 (0)