aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMLogger+ASL.m
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2016-02-23 12:40:30 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-02-23 12:40:30 -0500
commit55d88cb7b554029228a2d0e6e0624a429b66ed27 (patch)
tree3f93a9c4567520dd9738c1581186a64cbf15f9b9 /Foundation/GTMLogger+ASL.m
parente2a081579316bc905905e83acb5be55fd9aab508 (diff)
On iOS devices allow the current user/app to read the log messages it generates.
Diffstat (limited to 'Foundation/GTMLogger+ASL.m')
-rw-r--r--Foundation/GTMLogger+ASL.m17
1 files changed, 16 insertions, 1 deletions
diff --git a/Foundation/GTMLogger+ASL.m b/Foundation/GTMLogger+ASL.m
index 43375fe..3b35361 100644
--- a/Foundation/GTMLogger+ASL.m
+++ b/Foundation/GTMLogger+ASL.m
@@ -148,11 +148,26 @@
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];
}
@@ -161,7 +176,7 @@
// 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