421{
423 NSAutoreleasePool *rootPool =
nil, *pool =
nil;
425
426 rootPool = [[NSAutoreleasePool alloc] init];
427 [NSThread ooSetCurrentThreadName:@"OOLogOutputHandler logging thread"];
428
429
430 [messageQueue retain];
431 [threadStateMonitor lock];
432 [threadStateMonitor unlockWithCondition:kConditionWorking];
433
434 @try
435 {
436 for (;;)
437 {
438 pool = [[NSAutoreleasePool alloc] init];
439
440 message = [messageQueue dequeue];
441
442 if (!
sSaturated && [message isKindOfClass:[NSData
class]])
443 {
444 size += [message length];
446 {
448#if OOLITE_WINDOWS
449 message = @"\r\n\r\n\r\n***** LOG TRUNCATED DUE TO EXCESSIVE LENGTH *****\r\n";
450#else
451 message = @"\n\n\n***** LOG TRUNCATED DUE TO EXCESSIVE LENGTH *****\n";
452#endif
453 message = [message dataUsingEncoding:NSUTF8StringEncoding];
454 }
455
456 [logFile writeData:message];
457 }
458 else if ([message isEqual:@"flush"])
459 {
460 [logFile synchronizeFile];
461 }
462 else if ([message isEqual:@"die"])
463 {
464 break;
465 }
466
467 [pool release];
468 }
469 }
470 @catch (NSException *exception) {}
471 [pool release];
472
473
474 [messageQueue release];
475 [threadStateMonitor lock];
476 [threadStateMonitor unlockWithCondition:kConditionReadyToDealloc];
477
478 [rootPool release];
479}