Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ARLogv, non-variadic version of ARLog, for Swift interop. #279

Merged
merged 2 commits into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ARAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@

/// an NSLog-like command that send to providers
extern void ARLog (NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
extern void ARLogv (NSString *format, va_list argList) NS_FORMAT_FUNCTION(1,0);

/// A try-catch for nil protection wrapped event
extern void ARAnalyticsEvent (NSString *event, NSDictionary *properties);
Expand Down
16 changes: 8 additions & 8 deletions ARAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -759,18 +759,20 @@ - (void)iterateThroughProviders:(void(^)(ARAnalyticalProvider *provider))provide
@end

void ARLog (NSString *format, ...) {
va_list argList;
va_start(argList, format);
ARLogv(format, argList);
va_end(argList);
}

void ARLogv (NSString *format, va_list argList) {
if (format == nil) {
if (_ARLogShouldPrintStdout) {
printf("nil \n");
}
return;
}
// Get a reference to the arguments that follow the format parameter
va_list argList;
va_start(argList, format);

// Perform format string argument substitution, reinstate %% escapes, then print


@autoreleasepool {
NSString *parsedFormatString = [[NSString alloc] initWithFormat:format arguments:argList];
parsedFormatString = [parsedFormatString stringByReplacingOccurrencesOfString:@"%%" withString:@"%%%%"];
Expand All @@ -782,8 +784,6 @@ void ARLog (NSString *format, ...) {
[provider remoteLog:parsedFormatString];
}];
}

va_end(argList);
}

void ARAnalyticsEvent (NSString *event, NSDictionary *properties) {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Master

* Added ARLogv function for Switft interop (@ibrt)
* Changed import method for Localytics (@cemaleker)
* changed return type of init methods to instancetype instead of id (@BenchR267)
* Added support for Appboy (@BenchR267)
Expand Down