Skip to content

Commit c264df1

Browse files
authored
fix LPLog method to use formatted string (#397)
1 parent 31057fb commit c264df1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Leanplum-SDK/Classes/Managers/LPLogManager.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ + (void)logInternalError:(NSException *)e
109109
@end
110110

111111
void LPLog(LPLogType type , NSString *format, ...) {
112+
va_list vargs;
113+
va_start(vargs, format);
114+
NSString *formattedMessage = [[NSString alloc] initWithFormat:format arguments:vargs];
115+
va_end(vargs);
116+
112117
LPLogLevel level = [LPLogManager logLevel];
113118
NSString *message = nil;
114119
NSString *leanplumString = @"LEANPLUM";
@@ -117,23 +122,23 @@ void LPLog(LPLogType type , NSString *format, ...) {
117122
switch (type) {
118123
case LPDebug:
119124
logType = @"DEBUG";
120-
message = [NSString stringWithFormat:@"[%@] [%@]: %@", leanplumString, logType, format];
125+
message = [NSString stringWithFormat:@"[%@] [%@]: %@", leanplumString, logType, formattedMessage];
121126
[LPLogManager maybeSendLog:message];
122127
if (level < Debug) {
123128
return;
124129
}
125130
break;
126131
case LPInfo:
127132
logType = @"INFO";
128-
message = [NSString stringWithFormat:@"[%@] [%@]: %@", leanplumString, logType, format];
133+
message = [NSString stringWithFormat:@"[%@] [%@]: %@", leanplumString, logType, formattedMessage];
129134
[LPLogManager maybeSendLog:message];
130135
if (level < Info) {
131136
return;
132137
}
133138
break;
134139
case LPError:
135140
logType = @"ERROR";
136-
message = [NSString stringWithFormat:@"[%@] [%@]: %@", leanplumString, logType, format];
141+
message = [NSString stringWithFormat:@"[%@] [%@]: %@", leanplumString, logType, formattedMessage];
137142
[LPLogManager maybeSendLog:message];
138143
if (level < Error) {
139144
return;

0 commit comments

Comments
 (0)