This commit is contained in:
lawrencelomax 2016-02-03 12:47:46 +00:00
Родитель 71831ed1b0
Коммит 509308ad28
2 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -74,4 +74,13 @@
*/
+ (id<FBSimulatorLogger>)aslLoggerWritingToStderrr:(BOOL)writeToStdErr withDebugLogging:(BOOL)debugLogging;
/**
An implementation of `FBSimulatorLogger` that logs all to a file descriptor using ASL.
@param fileDescriptor the file descriptor to log to, if 0 no file descriptor logging will occur.
@param debugLogging YES if Debug messages should be written to stderr, NO otherwise.
@return an FBSimulatorLogger instance.
*/
+ (id<FBSimulatorLogger>)aslLoggerWritingToFileDescriptor:(int)fileDescriptor withDebugLogging:(BOOL)debugLogging;
@end

Просмотреть файл

@ -135,14 +135,15 @@ static const char *FBASLClientDispatchLocal = "fbsimulatorcontrol_asl_client";
+ (id<FBSimulatorLogger>)aslLoggerWritingToStderrr:(BOOL)writeToStdErr withDebugLogging:(BOOL)debugLogging
{
static dispatch_once_t onceToken;
static FBSimulatorLogger_ASL *logger;
dispatch_once(&onceToken, ^{
int fileDescriptor = writeToStdErr ? STDERR_FILENO : 0;
FBASLClientManager *clientManager = [[FBASLClientManager alloc] initWithWritingToFileDescriptor:fileDescriptor debugLogging:debugLogging];
asl_object_t client = [clientManager clientHandleForQueue:dispatch_get_main_queue()];
logger = [[FBSimulatorLogger_ASL alloc] initWithClientManager:clientManager client:client currentLevel:ASL_LEVEL_INFO prefix:nil];
});
int fileDescriptor = writeToStdErr ? STDERR_FILENO : 0;
return [self aslLoggerWritingToFileDescriptor:fileDescriptor withDebugLogging:debugLogging];
}
+ (id<FBSimulatorLogger>)aslLoggerWritingToFileDescriptor:(int)fileDescriptor withDebugLogging:(BOOL)debugLogging
{
FBASLClientManager *clientManager = [[FBASLClientManager alloc] initWithWritingToFileDescriptor:fileDescriptor debugLogging:debugLogging];
asl_object_t client = [clientManager clientHandleForQueue:dispatch_get_main_queue()];
FBSimulatorLogger_ASL *logger = [[FBSimulatorLogger_ASL alloc] initWithClientManager:clientManager client:client currentLevel:ASL_LEVEL_INFO prefix:nil];
return logger;
}