Oolite
Loading...
Searching...
No Matches
OOLoggingExtended.h File Reference
import "OOLogging.h"
Include dependency graph for OOLoggingExtended.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void OOLogSetDisplayMessagesInClass (NSString *inClass, BOOL inFlag)
NSString * OOLogGetParentMessageClass (NSString *inClass)
void OOLoggingInit (void)
void OOLoggingTerminate (void)
void OOLogInsertMarker (void)
BOOL OOLogShowFunction (void)
void OOLogSetShowFunction (BOOL flag)
BOOL OOLogShowFileAndLine (void)
void OOLogSetShowFileAndLine (BOOL flag)
BOOL OOLogShowTime (void)
void OOLogSetShowTime (BOOL flag)
BOOL OOLogShowMessageClass (void)
void OOLogSetShowMessageClass (BOOL flag)
void OOLogSetShowMessageClassTemporary (BOOL flag)
NSString * OOLogAbbreviatedFileName (const char *inName)

Function Documentation

◆ OOLogAbbreviatedFileName()

NSString * OOLogAbbreviatedFileName ( const char * inName)

Definition at line 762 of file OOLogging.m.

763{
764 NSString* name = nil;
765
766 if (EXPECT_NOT(inName == NULL))
767 return @"unspecified file";
768
769 [sLock lock];
770 name = NSMapGet(sFileNamesCache, inName);
771 if (EXPECT_NOT(name == nil)) {
772 name = [[NSString stringWithUTF8String:inName] lastPathComponent];
773 NSMapInsertKnownAbsent(sFileNamesCache, inName, name);
774 }
775 [sLock unlock];
776
777 return name;
778}
#define EXPECT_NOT(x)
static NSLock * sLock
Definition OOLogging.m:76
static NSMapTable * sFileNamesCache
Definition OOLogging.m:115
return nil

References EXPECT_NOT, nil, and sFileNamesCache.

Referenced by OOJSStopTimeLimiter_(), and OOJSUnreachable().

Here is the caller graph for this function:

◆ OOLogGetParentMessageClass()

NSString * OOLogGetParentMessageClass ( NSString * inClass)

Definition at line 194 of file OOLogging.m.

195{
196 NSRange range;
197
198 if (inClass == nil)
199 return nil;
200
201 range = [inClass rangeOfString:@"." options:NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch]; // Only NSBackwardsSearch is important, others are optimizations
202 if (range.location == NSNotFound)
203 return nil;
204
205 return [inClass substringToIndex:range.location];
206}

References nil.

Referenced by ResolveDisplaySetting().

Here is the caller graph for this function:

◆ OOLoggingInit()

void OOLoggingInit ( void )

Definition at line 534 of file OOLogging.m.

535{
536 NSAutoreleasePool* pool = nil;
537
538 if (sInited)
539 return;
540
541 pool = [[NSAutoreleasePool alloc] init];
542
543 sLock = [[NSLock alloc] init];
544 [sLock setName:@"OOLogging lock"];
545 if (sLock == nil)
546 exit(EXIT_FAILURE);
547
548#ifndef OOLOG_NO_FILE_NAME
549 sFileNamesCache = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, NSObjectMapValueCallBacks, 100);
550#endif
551
552 sInited = YES; // Must be before OOLogOutputHandlerInit().
554
556
558
559 [pool release];
560}
static BOOL sInited
Definition OOCPUInfo.m:56
void OOPrintLogHeader(void)
Definition OOLogHeader.m:57
void OOLogOutputHandlerInit(void)
static void LoadExplicitSettings(void)
Definition OOLogging.m:650

References LoadExplicitSettings(), nil, OOLogOutputHandlerInit(), OOPrintLogHeader(), sFileNamesCache, sInited, and sLock.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOLoggingTerminate()

void OOLoggingTerminate ( void )

Definition at line 562 of file OOLogging.m.

563{
564 if (!sInited)
565 return;
566
568
569 /* We do not set sInited to NO. Instead, the output handler is required
570 to be able to handle working even after being closed. Under OS X, this
571 is done by writing to stderr in this case; on other platforms, NSLog()
572 is used and OOLogOutputHandlerClose() is a no-op.
573 */
574}
void OOLogOutputHandlerClose(void)

References OOLogOutputHandlerClose(), and sInited.

Referenced by GameController::applicationShouldTerminate:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOLogInsertMarker()

void OOLogInsertMarker ( void )

Definition at line 581 of file OOLogging.m.

582{
583 static unsigned lastMarkerID = 0;
584 unsigned thisMarkerID;
585 NSString* marker = nil;
586
587 [sLock lock];
588 thisMarkerID = ++lastMarkerID;
589 [sLock unlock];
590
591 marker = [NSString stringWithFormat:@"\n\n========== [Marker %u] ==========", thisMarkerID];
593}
void OOLogOutputHandlerPrint(NSString *string)

References nil, and OOLogOutputHandlerPrint().

Here is the call graph for this function:

◆ OOLogSetDisplayMessagesInClass()

void OOLogSetDisplayMessagesInClass ( NSString * inClass,
BOOL inFlag )

Definition at line 172 of file OOLogging.m.

173{
174 id value = nil;
175
176 if (!Inited())
177 return;
178
179 [sLock lock];
180 value = [sExplicitSettings objectForKey:inClass];
181 if (value == nil || value != CacheValue(inFlag)) {
182 OOLogInternal(OOLOG_SETTING_SET, @"Setting %@ to %s", inClass, inFlag ? "ON" : "OFF");
183
184 [sExplicitSettings setObject:CacheValue(inFlag) forKey:inClass];
185
186 // Clear cache and let it be rebuilt as needed.
188 } else {
189 OOLogInternal(OOLOG_SETTING_SET, @"Keeping %@ %s", inClass, inFlag ? "ON" : "OFF");
190 }
191 [sLock unlock];
192}
#define DESTROY(x)
static NSMutableDictionary * sExplicitSettings
Definition OOLogging.m:77
OOINLINE BOOL Inited(void)
Definition OOLogging.m:128
#define OOLOG_SETTING_SET
Definition OOLogging.m:59
#define OOLogInternal(cond, format,...)
Definition OOLogging.m:97
OOINLINE id CacheValue(BOOL inValue) PURE_FUNC
Definition OOLogging.m:120
static NSMutableDictionary * sDerivedSettingsCache
Definition OOLogging.m:78

References CacheValue(), DESTROY, Inited(), nil, OOLOG_SETTING_SET, OOLogInternal, and sDerivedSettingsCache.

Referenced by PlayerEntity(Scripting)::debugOff, PlayerEntity(Scripting)::debugOn, GameController::endSplashScreen, OOPListSchemaVerifier::initWithSchema:, PlayerEntity(OOControlsPrivate)::pollFlightControls:, and OOOXPVerifier(OOPrivate)::setUpLogOverrides.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOLogSetShowFileAndLine()

void OOLogSetShowFileAndLine ( BOOL flag)

Definition at line 489 of file OOLogging.m.

490{
491 flag = !!flag; // YES or NO, not 42.
492
493 if (flag != sShowFileAndLine) {
494 sShowFileAndLine = flag;
495 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:@"logging-show-file-and-line"];
496 }
497}
static BOOL sShowFileAndLine
Definition OOLogging.m:84

References sShowFileAndLine.

◆ OOLogSetShowFunction()

void OOLogSetShowFunction ( BOOL flag)

Definition at line 474 of file OOLogging.m.

475{
476 flag = !!flag; // YES or NO, not 42.
477
478 if (flag != sShowFunction) {
479 sShowFunction = flag;
480 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:@"logging-show-function"];
481 }
482}
static BOOL sShowFunction
Definition OOLogging.m:83

References sShowFunction.

◆ OOLogSetShowMessageClass()

void OOLogSetShowMessageClass ( BOOL flag)

Definition at line 519 of file OOLogging.m.

520{
521 flag = !!flag; // YES or NO, not 42.
522
523 if (flag != sShowClass) {
524 sShowClass = flag;
525 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:@"logging-show-class"];
526 }
527}
static BOOL sShowClass
Definition OOLogging.m:86

References sShowClass.

◆ OOLogSetShowMessageClassTemporary()

void OOLogSetShowMessageClassTemporary ( BOOL flag)

Definition at line 529 of file OOLogging.m.

530{
531 sShowClass = !!flag; // YES or NO, not 42.
532}

References sShowClass.

Referenced by OOOXPVerifier(OOPrivate)::setUpLogOverrides.

Here is the caller graph for this function:

◆ OOLogSetShowTime()

void OOLogSetShowTime ( BOOL flag)

Definition at line 504 of file OOLogging.m.

505{
506 flag = !!flag; // YES or NO, not 42.
507
508 if (flag != sShowTime) {
509 sShowTime = flag;
510 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:@"logging-show-time"];
511 }
512}
static BOOL sShowTime
Definition OOLogging.m:85

References sShowTime.

◆ OOLogShowFileAndLine()

BOOL OOLogShowFileAndLine ( void )

Definition at line 484 of file OOLogging.m.

485{
486 return sShowFileAndLine;
487}

References sShowFileAndLine.

◆ OOLogShowFunction()

BOOL OOLogShowFunction ( void )

Definition at line 469 of file OOLogging.m.

470{
471 return sShowFunction;
472}

References sShowFunction.

◆ OOLogShowMessageClass()

BOOL OOLogShowMessageClass ( void )

Definition at line 514 of file OOLogging.m.

515{
516 return sShowClass;
517}

References sShowClass.

◆ OOLogShowTime()

BOOL OOLogShowTime ( void )

Definition at line 499 of file OOLogging.m.

500{
501 return sShowTime;
502}

References sShowTime.