Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
Macros | Functions | Variables
OOLogging.h File Reference
import "OOCocoa.h"
import "OOFunctionAttributes.h"
#include <stdarg.h>
+ Include dependency graph for OOLogging.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OOLOG_SHORT_CIRCUIT   1
 
#define OOLog(class, format, ...)   do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLine(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, ## __VA_ARGS__); }} while (0)
 
#define OOLogWithArguments(class, format, args)   do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLineAndArguments(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, args); }} while (0)
 
#define OOLogIndentIf(class)   do { if (OOLogWillDisplayMessagesInClass(class)) OOLogIndent(); } while (0)
 
#define OOLogOutdentIf(class)   do { if (OOLogWillDisplayMessagesInClass(class)) OOLogOutdent(); } while (0)
 
#define OOLOG_ERROR_PREFIX   @"***** ERROR: "
 
#define OOLOG_WARNING_PREFIX   @"----- WARNING: "
 
#define OOLogERR(class, format, ...)   OOLogWithPrefix(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, OOLOG_ERROR_PREFIX ,format, ## __VA_ARGS__)
 
#define OOLogWARN(class, format, ...)   OOLogWithPrefix(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, OOLOG_WARNING_PREFIX, format, ## __VA_ARGS__)
 
#define OOLogGenericParameterError()   OOLogGenericParameterErrorForFunction(OOLOG_FUNCTION_NAME)
 
#define OOLogGenericSubclassResponsibility()   OOLogGenericSubclassResponsibilityForFunction(OOLOG_FUNCTION_NAME)
 
#define NSLog(format, ...)   OOLog(kOOLogUnconvertedNSLog, format, ## __VA_ARGS__)
 
#define NSLogv(format, args)   OOLogWithArguments(kOOLogUnconvertedNSLog, format, args)
 
#define OODebugLog(class, format, ...)   do { (void)class; if (0) (void)format; } while (0)
 
#define OOExtraLog   OOLog
 

Functions

BOOL OOLogWillDisplayMessagesInClass (NSString *inMessageClass)
 
void OOLogIndent (void)
 
void OOLogOutdent (void)
 
void OOLogPushIndent (void)
 
void OOLogPopIndent (void)
 
void OOLogWithPrefix (NSString *inMessageClass, const char *inFunction, const char *inFile, unsigned long inLine, NSString *inPrefix, NSString *inFormat,...) OO_TAKES_FORMAT_STRING(6
 
void void OOLogWithFunctionFileAndLine (NSString *inMessageClass, const char *inFunction, const char *inFile, unsigned long inLine, NSString *inFormat,...) OO_TAKES_FORMAT_STRING(5
 
void void void OOLogWithFunctionFileAndLineAndArguments (NSString *inMessageClass, const char *inFunction, const char *inFile, unsigned long inLine, NSString *inFormat, va_list inArguments) OO_TAKES_FORMAT_STRING(5
 
void OOLogGenericParameterErrorForFunction (const char *inFunction)
 
void OOLogGenericSubclassResponsibilityForFunction (const char *inFunction)
 

Variables

NSString *const kOOLogSubclassResponsibility
 
NSString *const kOOLogParameterError
 
NSString *const kOOLogDeprecatedMethod
 
NSString *const kOOLogAllocationFailure
 
NSString *const kOOLogInconsistentState
 
NSString *const kOOLogException
 
NSString *const kOOLogFileNotFound
 
NSString *const kOOLogFileNotLoaded
 
NSString *const kOOLogOpenGLError
 
NSString *const kOOLogUnconvertedNSLog
 

Macro Definition Documentation

◆ NSLog

#define NSLog ( format,
... )   OOLog(kOOLogUnconvertedNSLog, format, ## __VA_ARGS__)

Definition at line 137 of file OOLogging.h.

Referenced by DirectoryExistCreatingIfNecessary().

◆ NSLogv

#define NSLogv ( format,
args )   OOLogWithArguments(kOOLogUnconvertedNSLog, format, args)

Definition at line 138 of file OOLogging.h.

◆ OODebugLog

#define OODebugLog ( class,
format,
... )   do { (void)class; if (0) (void)format; } while (0)

Definition at line 146 of file OOLogging.h.

◆ OOExtraLog

#define OOExtraLog   OOLog

Definition at line 152 of file OOLogging.h.

Referenced by Universe::addEntity:.

◆ OOLog

#define OOLog ( class,
format,
... )   do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLine(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, ## __VA_ARGS__); }} while (0)

Definition at line 88 of file OOLogging.h.

Referenced by OOMeshToOctreeConverter::addTriangle:, OOConcreteTexture::apply, CacheRemoveOldest(), CanonicalizeMaterialSpecifier(), ClassifyLHSConditionSelector(), AI::clearAllData, NSFileManager(OOExtensions)::commanderContentsOfPath:, CompileSystemDescriptions(), NSString(OOJavaScriptExtensions)::concatenationOfStringsFromJavaScriptValues:count:separator:inContext:, CopyDataFromFile(), OOScript::descriptionComponents, DumpVariable(), ErrorCallback(), ExportSystemDescriptions(), fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), TextureStore::getCloudTextureNameFor:color:impress:intoData:width:height:, GetShaderSource(), GLDumpCullingState(), GLDumpFogState(), GLDumpLightState(), GLDumpMaterialState(), GLDumpStateFlags(), GlobalLog(), NSThread(MethodsThatMayExistDependingOnSystem)::isMainThread, KeyToIndex(), LogOpenGLState(), MissionRunCallback(), OOCheckOpenGLErrors(), OOCPUInfoInit(), OOGenerateMipMaps(), OOInterpretTextureSpecifier(), OOJSDumpStack(), OOJSStartTimeLimiterWithTimeLimit_(), OOJSStopTimeLimiter_(), OOJSUnreachable(), OOLogGenericParameterErrorForFunction(), OOLogGenericSubclassResponsibilityForFunction(), OOLogOutputHandlerInit(), OOPrintLogHeader(), OOPropertyListFromData(), OORandomPositionInCylinder(), OOSanitizeLegacyScriptConditionsInternal(), OOSanitizeLegacyScriptInternal(), OOStandardsInternal(), PNGError(), PNGWarning(), RemoveCallbackAtIndex(), ReportJSError(), SanitizeActionStatement(), SanitizeCondition(), SanitizeConditionalStatement(), SwitchLogFile(), TessVertexCallback(), TreeInsert(), TreeSplay(), ValueIfClass(), Universe::VerifyDescString, and VerifyOpenGLStateInternal().

◆ OOLOG_ERROR_PREFIX

#define OOLOG_ERROR_PREFIX   @"***** ERROR: "

Definition at line 109 of file OOLogging.h.

◆ OOLOG_SHORT_CIRCUIT

#define OOLOG_SHORT_CIRCUIT   1

Definition at line 66 of file OOLogging.h.

◆ OOLOG_WARNING_PREFIX

#define OOLOG_WARNING_PREFIX   @"----- WARNING: "

Definition at line 110 of file OOLogging.h.

◆ OOLogERR

#define OOLogERR ( class,
format,
... )   OOLogWithPrefix(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, OOLOG_ERROR_PREFIX ,format, ## __VA_ARGS__)

◆ OOLogGenericParameterError

#define OOLogGenericParameterError ( )    OOLogGenericParameterErrorForFunction(OOLOG_FUNCTION_NAME)

Definition at line 125 of file OOLogging.h.

Referenced by EnsureCorrectDataSize(), EntityFromArgumentList(), and OOScalePixMap().

◆ OOLogGenericSubclassResponsibility

#define OOLogGenericSubclassResponsibility ( )    OOLogGenericSubclassResponsibilityForFunction(OOLOG_FUNCTION_NAME)

Definition at line 129 of file OOLogging.h.

◆ OOLogIndentIf

#define OOLogIndentIf ( class)    do { if (OOLogWillDisplayMessagesInClass(class)) OOLogIndent(); } while (0)

Definition at line 101 of file OOLogging.h.

Referenced by OOScript::descriptionComponents.

◆ OOLogOutdentIf

#define OOLogOutdentIf ( class)    do { if (OOLogWillDisplayMessagesInClass(class)) OOLogOutdent(); } while (0)

Definition at line 102 of file OOLogging.h.

Referenced by OOScript::descriptionComponents.

◆ OOLogWARN

#define OOLogWARN ( class,
format,
... )   OOLogWithPrefix(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, OOLOG_WARNING_PREFIX, format, ## __VA_ARGS__)

◆ OOLogWithArguments

#define OOLogWithArguments ( class,
format,
args )   do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLineAndArguments(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, args); }} while (0)

Definition at line 89 of file OOLogging.h.

Function Documentation

◆ OOLogGenericParameterErrorForFunction()

void OOLogGenericParameterErrorForFunction ( const char * inFunction)

Definition at line 495 of file OOLogging.m.

496{
497 OOLog(kOOLogParameterError, @"***** %s: bad parameters. (This is an internal programming error, please report it.)", inFunction);
498}
#define OOLog(class, format,...)
Definition OOLogging.h:88
NSString *const kOOLogParameterError
Definition OOLogging.m:647

References kOOLogParameterError, and OOLog.

◆ OOLogGenericSubclassResponsibilityForFunction()

void OOLogGenericSubclassResponsibilityForFunction ( const char * inFunction)

Definition at line 501 of file OOLogging.m.

502{
503 OOLog(kOOLogSubclassResponsibility, @"***** %s is a subclass responsibility. (This is an internal programming error, please report it.)", inFunction);
504}
NSString *const kOOLogSubclassResponsibility
Definition OOLogging.m:646

References kOOLogSubclassResponsibility, and OOLog.

◆ OOLogIndent()

void OOLogIndent ( void )

Definition at line 366 of file OOLogging.m.

367{
368 INDENT_LOCK();
369
371
373}
OOINLINE unsigned GetIndentLevel(void) PURE_FUNC
Definition OOLogging.m:302
OOINLINE void SetIndentLevel(unsigned level)
Definition OOLogging.m:309
#define INDENT_LOCK()
Definition OOLogging.m:298
#define INDENT_UNLOCK()
Definition OOLogging.m:299

References GetIndentLevel(), INDENT_LOCK, INDENT_UNLOCK, and SetIndentLevel().

Referenced by GLDumpCullingState(), GLDumpFogState(), GLDumpLightState(), GLDumpMaterialState(), GLDumpStateFlags(), LogOpenGLState(), OOCheckOpenGLErrors(), OOLogIndentIf(), and VerifyOpenGLStateInternal().

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

◆ OOLogOutdent()

void OOLogOutdent ( void )

Definition at line 376 of file OOLogging.m.

377{
378 INDENT_LOCK();
379
380 unsigned indentLevel = GetIndentLevel();
381 if (indentLevel != 0) SetIndentLevel(indentLevel - 1);
382
384}

References GetIndentLevel(), INDENT_LOCK, INDENT_UNLOCK, and SetIndentLevel().

Referenced by GLDumpCullingState(), GLDumpFogState(), GLDumpLightState(), GLDumpMaterialState(), GLDumpStateFlags(), LogOpenGLState(), OOCheckOpenGLErrors(), OOLogOutdentIf(), and VerifyOpenGLStateInternal().

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

◆ OOLogPopIndent()

void OOLogPopIndent ( void )

Definition at line 340 of file OOLogging.m.

341{
342 OOLogIndentStackElement *elem = NULL;
343 NSMutableDictionary *threadDict = nil;
344 NSValue *val = nil;
345
346 threadDict = [[NSThread currentThread] threadDictionary];
347 val = [threadDict objectForKey:kIndentStackKey];
348
349 elem = [val pointerValue];
350
351 if (elem != NULL)
352 {
353 [threadDict setObject:[NSNumber numberWithUnsignedInt:elem->indent] forKey:kIndentLevelKey];
354 [threadDict setObject:[NSValue valueWithPointer:elem->link] forKey:kIndentStackKey];
355 free(elem);
356 }
357 else
358 {
359 OOLogInternal(OOLOG_BAD_POP_INDENT, @"OOLogPopIndent(): state stack underflow.");
360 }
361}
static NSString *const kIndentStackKey
Definition OOLogging.m:53
#define OOLogInternal(cond, format,...)
Definition OOLogging.m:106
static NSString *const kIndentLevelKey
Definition OOLogging.m:52
#define OOLOG_BAD_POP_INDENT
Definition OOLogging.m:68
return nil
OOLogIndentStackElement * link
Definition OOLogging.m:76

References nil, OOLOG_BAD_POP_INDENT, and OOLogInternal.

◆ OOLogPushIndent()

void OOLogPushIndent ( void )

Definition at line 316 of file OOLogging.m.

317{
318 OOLogIndentStackElement *elem = NULL;
319 NSMutableDictionary *threadDict = nil;
320 NSValue *val = nil;
321
322 elem = malloc(sizeof *elem);
323 if (elem != NULL)
324 {
325 threadDict = [[NSThread currentThread] threadDictionary];
326 val = [threadDict objectForKey:kIndentStackKey];
327
328 elem->indent = [[threadDict objectForKey:kIndentLevelKey] intValue];
329 elem->link = [val pointerValue];
330
331 /*
332 Clang static analyzer reports elem not released here. It is in fact
333 released in OOLogPopIndent().
334 */
335 [threadDict setObject:[NSValue valueWithPointer:elem] forKey:kIndentStackKey];
336 }
337}

References OOLogIndentStackElement::indent, OOLogIndentStackElement::link, and nil.

◆ OOLogWillDisplayMessagesInClass()

BOOL OOLogWillDisplayMessagesInClass ( NSString * inMessageClass)

Definition at line 144 of file OOLogging.m.

145{
146 id value = nil;
147
148 if (!Inited()) return NO;
149
151
152 [sLock lock];
153
154 // Look for cached value
155 value = [sDerivedSettingsCache objectForKey:inMessageClass];
156 if (EXPECT_NOT(value == nil))
157 {
158 @try
159 {
160 // No cached value.
161 value = ResolveDisplaySetting(inMessageClass);
162
163 if (value != nil)
164 {
165 if (EXPECT_NOT(sDerivedSettingsCache == nil)) sDerivedSettingsCache = [[NSMutableDictionary alloc] init];
166 [sDerivedSettingsCache setObject:value forKey:inMessageClass];
167 }
168 }
169 @catch (id exception)
170 {
171 [sLock unlock];
172 @throw exception;
173 }
174 }
175 [sLock unlock];
176
177 OOLogInternal(OOLOG_SETTING_RETRIEVE, @"%@ is %s", inMessageClass, (value == kTrueToken) ? "on" : "off");
178 return value == kTrueToken;
179}
#define EXPECT_NOT(x)
static NSString *const kTrueToken
Definition OOLogging.m:100
#define OOLOG_SETTING_RETRIEVE
Definition OOLogging.m:64
static BOOL sOverrideValue
Definition OOLogging.m:97
OOINLINE BOOL Inited(void)
Definition OOLogging.m:136
static NSLock * sLock
Definition OOLogging.m:83
static BOOL sOverrideInEffect
Definition OOLogging.m:96
static id ResolveDisplaySetting(NSString *inMessageClass)
Definition OOLogging.m:861
static NSMutableDictionary * sDerivedSettingsCache
Definition OOLogging.m:85

References EXPECT_NOT, Inited(), kTrueToken, nil, OOLOG_SETTING_RETRIEVE, OOLogInternal, ResolveDisplaySetting(), sDerivedSettingsCache, sOverrideInEffect, and sOverrideValue.

Referenced by ConsoleDisplayMessagesInClass(), GlobalLog(), LogOpenGLState(), OOCheckOpenGLErrors(), OOLogIndentIf(), OOLogOutdentIf(), OOLogWithFunctionFileAndLineAndArguments(), OOLogWithPrefix(), OONSLogCStringFunction(), ReportJSError(), SyntaxIssue(), and VerifyOpenGLStateInternal().

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

◆ OOLogWithFunctionFileAndLine()

void void OOLogWithFunctionFileAndLine ( NSString * inMessageClass,
const char * inFunction,
const char * inFile,
unsigned long inLine,
NSString * inFormat,
... )

Referenced by OONSLogCStringFunction().

+ Here is the caller graph for this function:

◆ OOLogWithFunctionFileAndLineAndArguments()

void void void OOLogWithFunctionFileAndLineAndArguments ( NSString * inMessageClass,
const char * inFunction,
const char * inFile,
unsigned long inLine,
NSString * inFormat,
va_list inArguments )

Referenced by SyntaxIssue().

+ Here is the caller graph for this function:

◆ OOLogWithPrefix()

void OOLogWithPrefix ( NSString * inMessageClass,
const char * inFunction,
const char * inFile,
unsigned long inLine,
NSString * inPrefix,
NSString * inFormat,
... )

Variable Documentation

◆ kOOLogAllocationFailure

NSString* const kOOLogAllocationFailure
extern

Definition at line 649 of file OOLogging.m.

Referenced by OOMeshToOctreeConverter::addTriangle:.

◆ kOOLogDeprecatedMethod

NSString* const kOOLogDeprecatedMethod
extern

Definition at line 648 of file OOLogging.m.

◆ kOOLogException

NSString* const kOOLogException
extern

Definition at line 651 of file OOLogging.m.

Referenced by AI::clearAllData, main(), MissionRunCallback(), and OOJSDumpStack().

◆ kOOLogFileNotFound

NSString* const kOOLogFileNotFound
extern

Definition at line 652 of file OOLogging.m.

Referenced by CopyDataFromFile(), and GetShaderSource().

◆ kOOLogFileNotLoaded

NSString* const kOOLogFileNotLoaded
extern

Definition at line 653 of file OOLogging.m.

◆ kOOLogInconsistentState

NSString* const kOOLogInconsistentState
extern

Definition at line 650 of file OOLogging.m.

◆ kOOLogOpenGLError

NSString* const kOOLogOpenGLError
extern

Definition at line 654 of file OOLogging.m.

Referenced by OOCheckOpenGLErrors().

◆ kOOLogParameterError

NSString* const kOOLogParameterError
extern

◆ kOOLogSubclassResponsibility

NSString* const kOOLogSubclassResponsibility
extern

Definition at line 646 of file OOLogging.m.

Referenced by OOLogGenericSubclassResponsibilityForFunction().

◆ kOOLogUnconvertedNSLog

NSString* const kOOLogUnconvertedNSLog
extern

Definition at line 655 of file OOLogging.m.