Log File Watcher
Log File Watcher
- Subject: Log File Watcher
- From: email@hidden
- Date: Mon, 5 Nov 2007 22:15:22 +0100
- Resent-date: Mon, 5 Nov 2007 22:18:24 +0100
- Resent-from: email@hidden
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
Hi there
I tried to make something like a log file watcher (like tail):
---
- (void)awakeFromNib {
logFile = [[NSFileHandle fileHandleForReadingAtPath:LOGFILE] init];
if (!logFile)
return;
[logFile seekToEndOfFile];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(fileDataAvailable:)
name:NSFileHandleReadCompletionNotification
object:logFile];
[logFile readInBackgroundAndNotify];
}
- (void)fileDataAvailable:(NSNotification*)note {
NSLog(@"new entry %@", [[NSString alloc] initWithData:
[[note userInfo] objectForKey:NSFileHandleNotificationDataItem]
encoding:NSUTF8StringEncoding]);
[logFile readInBackgroundAndNotify];
}
---
The problem is, I now get e "new entry" all the time... The [note
userInfo] is empty.
---
2007-11-05 22:11:26.502 MyApp[4381:10b] new entry
2007-11-05 22:11:26.504 MyApp[4381:10b] new entry
2007-11-05 22:11:26.504 MyApp[4381:10b] new entry
---
Any help is appreciated.
Nils
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden