Skip to content
Open
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
15 changes: 15 additions & 0 deletions Logging/SLLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ void SLLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
*/
void SLLogAsync(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);

/**
Asynchronously logs a warning message to the testing environment.

@param format A format string (in the manner of `-[NSString stringWithFormat:]`).
@param ... (Optional) A comma-separated list of arguments to substitute into `format`.
*/
void SLLogWarningAsync(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);

/**
Asynchronously logs an error message to the testing environment.

@param format A format string (in the manner of `-[NSString stringWithFormat:]`).
@param ... (Optional) A comma-separated list of arguments to substitute into `format`.
*/
void SLLogErrorAsync(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);

/**
The shared `SLLogger` used by Subliminal to log test progress. It may also be
Expand Down
22 changes: 22 additions & 0 deletions Logging/SLLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ void SLLogAsync(NSString *format, ...) {
});
}

void SLLogWarningAsync(NSString *format, ...) {
va_list args;
va_start(args, format);
NSString *message = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

dispatch_async([[SLLogger sharedLogger] loggingQueue], ^{
[[SLLogger sharedLogger] logWarning:message];
});
}

void SLLogErrorAsync(NSString *format, ...) {
va_list args;
va_start(args, format);
NSString *message = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

dispatch_async([[SLLogger sharedLogger] loggingQueue], ^{
[[SLLogger sharedLogger] logError:message];
});
}

@implementation SLLogger {
dispatch_queue_t _loggingQueue;
}
Expand Down