Skip to content

Commit 36643dd

Browse files
authored
Update BNCLog Logging Names (#618)
* Better naming for logging functions. More intuitive defaults.
1 parent 4bd421e commit 36643dd

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

Branch-SDK/Branch-SDK/BNCLog.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,20 @@ extern void BNCLogSetFlushFunction(BNCLogFlushFunctionPtr _Nullable flushFunctio
119119
extern BNCLogFlushFunctionPtr _Nullable BNCLogFlushFunction();
120120

121121

122-
#pragma mark - BNCLogMessageInternal
122+
#pragma mark - BNCLogWriteMessage
123123

124124

125-
/// The main logging function used in the logging defines.
126-
extern void BNCLogMessageInternal(
125+
/// The main logging function used in the variadic logging defines.
126+
extern void BNCLogWriteMessageFormat(
127127
BNCLogLevel logLevel,
128128
const char *_Nullable sourceFileName,
129129
int sourceLineNumber,
130130
id _Nullable messageFormat,
131131
...
132132
);
133133

134-
/// Swift-friendly wrapper for BNCLogMessageInternal
135-
extern void BNCLogMessageInternalSwift(
134+
/// Swift-friendly wrapper for BNCLogWriteMessageFormat
135+
extern void BNCLogWriteMessage(
136136
BNCLogLevel logLevel,
137137
NSString *_Nonnull sourceFileName,
138138
NSUInteger sourceLineNumber,
@@ -149,25 +149,25 @@ extern void BNCLogFlushMessages();
149149

150150
///@param format Log a debug message with the specified formatting.
151151
#define BNCLogDebug(...) \
152-
do { BNCLogMessageInternal(BNCLogLevelDebug, __FILE__, __LINE__, __VA_ARGS__); } while (0)
152+
do { BNCLogWriteMessageFormat(BNCLogLevelDebug, __FILE__, __LINE__, __VA_ARGS__); } while (0)
153153

154154
///@param format Log a warning message with the specified formatting.
155155
#define BNCLogWarning(...) \
156-
do { BNCLogMessageInternal(BNCLogLevelWarning, __FILE__, __LINE__, __VA_ARGS__); } while (0)
156+
do { BNCLogWriteMessageFormat(BNCLogLevelWarning, __FILE__, __LINE__, __VA_ARGS__); } while (0)
157157

158158
///@param format Log an error message with the specified formatting.
159159
#define BNCLogError(...) \
160-
do { BNCLogMessageInternal(BNCLogLevelError, __FILE__, __LINE__, __VA_ARGS__); } while (0)
160+
do { BNCLogWriteMessageFormat(BNCLogLevelError, __FILE__, __LINE__, __VA_ARGS__); } while (0)
161161

162162
///@param format Log a message with the specified formatting.
163163
#define BNCLog(...) \
164-
do { BNCLogMessageInternal(BNCLogLevelLog, __FILE__, __LINE__, __VA_ARGS__); } while (0)
164+
do { BNCLogWriteMessageFormat(BNCLogLevelLog, __FILE__, __LINE__, __VA_ARGS__); } while (0)
165165

166166
///Cause a programmatic breakpoint if breakpoints are enabled.
167167
#define BNCLogBreakPoint() \
168168
do { \
169169
if (BNCLogBreakPointsAreEnabled()) { \
170-
BNCLogMessageInternal(BNCLogLevelBreakPoint, __FILE__, __LINE__, @"Programmatic breakpoint."); \
170+
BNCLogWriteMessageFormat(BNCLogLevelBreakPoint, __FILE__, __LINE__, @"Programmatic breakpoint."); \
171171
if (BNCDebuggerIsAttached()) { \
172172
BNCLogFlushMessages(); \
173173
BNCDebugBreakpoint(); \
@@ -179,7 +179,7 @@ extern void BNCLogFlushMessages();
179179
#define BNCBreakPointWithMessage(...) \
180180
do { \
181181
if (BNCLogBreakPointsAreEnabled() { \
182-
BNCLogMessageInternal(BNCLogLevelBreakPoint, __FILE__, __LINE__, __VA_ARGS__); \
182+
BNCLogWriteMessageFormat(BNCLogLevelBreakPoint, __FILE__, __LINE__, __VA_ARGS__); \
183183
if (BNCDebuggerIsAttached()) { \
184184
BNCLogFlushMessages(); \
185185
BNCDebugBreakpoint(); \
@@ -191,7 +191,7 @@ extern void BNCLogFlushMessages();
191191
#define BNCLogAssert(condition) \
192192
do { \
193193
if (!(condition)) { \
194-
BNCLogMessageInternal(BNCLogLevelAssert, __FILE__, __LINE__, @"(%s) !!!", #condition); \
194+
BNCLogWriteMessageFormat(BNCLogLevelAssert, __FILE__, __LINE__, @"(%s) !!!", #condition); \
195195
if (BNCLogBreakPointsAreEnabled() && BNCDebuggerIsAttached()) { \
196196
BNCLogFlushMessages(); \
197197
BNCDebugBreakpoint(); \
@@ -205,7 +205,7 @@ extern void BNCLogFlushMessages();
205205
do { \
206206
if (!(condition)) { \
207207
NSString *m = [NSString stringWithFormat:message, __VA_ARGS__]; \
208-
BNCLogMessageInternal(BNCLogLevelAssert, __FILE__, __LINE__, @"(%s) !!! %@", #condition, m); \
208+
BNCLogWriteMessageFormat(BNCLogLevelAssert, __FILE__, __LINE__, @"(%s) !!! %@", #condition, m); \
209209
if (BNCLogBreakPointsAreEnabled() && BNCDebuggerIsAttached()) { \
210210
BNCLogFlushMessages(); \
211211
BNCDebugBreakpoint(); \

Branch-SDK/Branch-SDK/BNCLog.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void BNCLogSetBreakPointsEnabled(BOOL enabled) {
463463

464464
#pragma mark - Log Functions
465465

466-
static BNCLogOutputFunctionPtr bnc_LoggingFunction = BNCLogFunctionOutputToStdOut;
466+
static BNCLogOutputFunctionPtr bnc_LoggingFunction = nil; // Default to just NSLog output.
467467
static BNCLogFlushFunctionPtr bnc_LogFlushFunction = BNCLogFlushFileDescriptor;
468468

469469
BNCLogOutputFunctionPtr _Nullable BNCLogOutputFunction() {
@@ -498,7 +498,7 @@ void BNCLogSetFlushFunction(BNCLogFlushFunctionPtr flushFunction) {
498498

499499
static dispatch_queue_t bnc_LogQueue = nil;
500500

501-
void BNCLogMessageInternal(
501+
void BNCLogWriteMessageFormat(
502502
BNCLogLevel logLevel,
503503
const char *_Nullable file,
504504
int lineNumber,
@@ -551,13 +551,13 @@ void BNCLogMessageInternal(
551551
}
552552
}
553553

554-
void BNCLogMessageInternalSwift(
554+
void BNCLogWriteMessage(
555555
BNCLogLevel logLevel,
556556
NSString *_Nonnull file,
557557
NSUInteger lineNumber,
558558
NSString *_Nonnull message
559559
) {
560-
BNCLogMessageInternal(logLevel, file.UTF8String, (int)lineNumber, @"%@", message);
560+
BNCLogWriteMessageFormat(logLevel, file.UTF8String, (int)lineNumber, @"%@", message);
561561
}
562562

563563
void BNCLogFlushMessages() {

Examples/WebViewExample/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use_frameworks!
2+
platform :ios, '9.0'
23

34
# ----- Branch pod
45
#

Examples/WebViewExample/WebViewExample.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
);
227227
runOnlyForDeploymentPostprocessing = 0;
228228
shellPath = /bin/sh;
229-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
229+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
230230
showEnvVarsInLog = 0;
231231
};
232232
DF74DA356D0CBFBBC39E6377 /* [CP] Copy Pods Resources */ = {

Examples/WebViewExample/WebViewExample/AppDelegate.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1717
// MARK: - UIApplicationDelegate methods
1818

1919
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
20-
BNCLogSetOutputFunction(nil)
2120

2221
// Store the NavigationController for later link routing.
2322
navigationController = window?.rootViewController as? NavigationController
@@ -33,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3332
guard let buo = buo else { return }
3433
self.routeURLFromBranch(buo)
3534
}
36-
35+
3736
return true
3837
}
3938

Examples/WebViewExample/WebViewExample/Utilities/BNCLog.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Branch
1616
* - line: (unused) provides the Swift line number
1717
*/
1818
func BNCLogDebug(_ message: String, _ file: String=#file, _ line: UInt=#line) {
19-
BNCLogMessageInternalSwift(.debug, file, line, message)
19+
BNCLogWriteMessage(.debug, file, line, message)
2020
}
2121

2222
/**
@@ -27,7 +27,7 @@ func BNCLogDebug(_ message: String, _ file: String=#file, _ line: UInt=#line) {
2727
* - line: (unused) provides the Swift line number
2828
*/
2929
func BNCLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
30-
BNCLogMessageInternalSwift(.error, file, line, message)
30+
BNCLogWriteMessage(.error, file, line, message)
3131
}
3232

3333
/**
@@ -38,7 +38,7 @@ func BNCLogError(_ message: String, _ file: String=#file, _ line: UInt=#line) {
3838
* - line: (unused) provides the Swift line number
3939
*/
4040
func BNCLog(_ message: String, _ file: String=#file, _ line: UInt=#line) {
41-
BNCLogMessageInternalSwift(.log, file, line, message)
41+
BNCLogWriteMessage(.log, file, line, message)
4242
}
4343

4444
/**
@@ -49,5 +49,5 @@ func BNCLog(_ message: String, _ file: String=#file, _ line: UInt=#line) {
4949
* - line: (unused) provides the Swift line number
5050
*/
5151
func BNCLogWarning(_ message: String, _ file: String=#file, _ line: UInt=#line) {
52-
BNCLogMessageInternalSwift(.warning, file, line, message)
52+
BNCLogWriteMessage(.warning, file, line, message)
5353
}

0 commit comments

Comments
 (0)