Skip to content

Commit

Permalink
Merge pull request #112 from thomasvl/update
Browse files Browse the repository at this point in the history
Two small tweaks
  • Loading branch information
thomasvl committed Feb 23, 2016
2 parents faf61e3 + 55d88cb commit 0e9fdcf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions Foundation/GTMLogger+ASL.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
@interface GTMLoggerASLClient : NSObject {
@private
aslclient client_;
aslmsg msgOptions_;
}

// Designated initializer, |facility| is supplied to asl_open().
Expand Down
17 changes: 16 additions & 1 deletion Foundation/GTMLogger+ASL.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,26 @@ - (id)initWithFacility:(NSString *)facility {
return nil;
// COV_NF_END
}
#if TARGET_OS_IPHONE
// On iOS we need to flag the messages as available for read so
// asl_search() can see our own output.
msgOptions_ = asl_new(ASL_TYPE_MSG);
if ((msgOptions_ == NULL) ||
(asl_set(msgOptions_,
ASL_KEY_READ_UID,
[[NSString stringWithFormat:@"%d", getuid()] UTF8String]) != 0)) {
// COV_NF_START - no real way to test this
[self release];
return nil;
// COV_NF_END
}
#endif
}
return self;
}

- (void)dealloc {
if (msgOptions_ != NULL) asl_free(msgOptions_);
if (client_ != NULL) asl_close(client_);
[super dealloc];
}
Expand All @@ -161,7 +176,7 @@ - (void)dealloc {
// logs with test messages.
// COV_NF_START
- (void)log:(NSString *)msg level:(int)level {
asl_log(client_, NULL, level, "%s", [msg UTF8String]);
asl_log(client_, msgOptions_, level, "%s", [msg UTF8String]);
}
// COV_NF_END

Expand Down
2 changes: 1 addition & 1 deletion Foundation/GTMSystemVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ + (void)initialize {
// version number instead of an iOS version number.
Class uideviceClass = NSClassFromString(@"UIDevice");
if (uideviceClass) {
id currentDevice = objc_msgSend(uideviceClass, @selector(currentDevice));
id currentDevice = ((id (*)(id, SEL))objc_msgSend)(uideviceClass, @selector(currentDevice));
version = [currentDevice performSelector:@selector(systemVersion)];
}
if (!version) {
Expand Down
2 changes: 1 addition & 1 deletion UnitTesting/GTMSenTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ - (void)invokeTest {
// It turns out that on iOS4 (and 3.2) exceptions thrown inside an
// [invocation invoke] on the simulator cannot be caught.
// http://openradar.appspot.com/8081169
objc_msgSend(self, [invocation selector]);
((void (*)(id, SEL))objc_msgSend)(self, [invocation selector]);
#else
[invocation invokeWithTarget:self];
#endif
Expand Down

0 comments on commit 0e9fdcf

Please sign in to comment.