Fiddled with logging, made OS X debug menu load a little later so that its file lookup is affected by data cache rebuilding.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1075 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
78275bee85
commit
839cc06cf0
@ -2805,7 +2805,10 @@
|
|||||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||||
GCC_OPTIMIZATION_LEVEL = s;
|
GCC_OPTIMIZATION_LEVEL = s;
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = XP_UNIX;
|
GCC_PREPROCESSOR_DEFINITIONS = XP_UNIX;
|
||||||
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = NDEBUG;
|
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = (
|
||||||
|
NDEBUG,
|
||||||
|
OOLOG_NO_FILE_NAME,
|
||||||
|
);
|
||||||
GCC_REUSE_STRINGS = YES;
|
GCC_REUSE_STRINGS = YES;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
"$(HEADER_SEARCH_PATHS_QUOTED_1)",
|
"$(HEADER_SEARCH_PATHS_QUOTED_1)",
|
||||||
|
@ -108,14 +108,20 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)awakeFromNib
|
|
||||||
{
|
|
||||||
#if OO_INCLUDE_DEBUG_CONTROLLER
|
#if OO_INCLUDE_DEBUG_CONTROLLER
|
||||||
(void)[OODebugController sharedDebugController];
|
- (void)awakeFromNib
|
||||||
#endif
|
{
|
||||||
|
[self performSelector:@selector(createDebugController) withObject:nil afterDelay:0.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)createDebugController
|
||||||
|
{
|
||||||
|
(void)[OODebugController sharedDebugController];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
- (void) setStringInput: (enum StringInput) value
|
- (void) setStringInput: (enum StringInput) value
|
||||||
{
|
{
|
||||||
allowingStringInput = value;
|
allowingStringInput = value;
|
||||||
|
@ -54,11 +54,34 @@ SOFTWARE.
|
|||||||
#import "OOAsyncQueue.h"
|
#import "OOAsyncQueue.h"
|
||||||
#import <stdlib.h>
|
#import <stdlib.h>
|
||||||
#import <stdio.h>
|
#import <stdio.h>
|
||||||
|
#import <sys/sysctl.h>
|
||||||
|
|
||||||
|
|
||||||
#undef NSLog // We need to be able to call the real NSLog.
|
#undef NSLog // We need to be able to call the real NSLog.
|
||||||
|
|
||||||
|
|
||||||
|
// Define CPU_TYPE_STRING for log preamble. Must be a C string literal.
|
||||||
|
#if defined (__ppc__)
|
||||||
|
#define CPU_TYPE_STRING_BASE "PPC-32"
|
||||||
|
#elif defined (__ppc64__)
|
||||||
|
#define CPU_TYPE_STRING_BASE "PPC-64"
|
||||||
|
#elif defined (__i386__)
|
||||||
|
#define CPU_TYPE_STRING_BASE "x86-32"
|
||||||
|
#elif defined (__x86_64__)
|
||||||
|
#define CPU_TYPE_STRING_BASE "x86-64"
|
||||||
|
#else
|
||||||
|
#define CPU_TYPE_STRING_BASE "Unknown architecture!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OO_DEBUG
|
||||||
|
#define CPU_TYPE_STRING CPU_TYPE_STRING_BASE " debug"
|
||||||
|
#elif !defined (NDEBUG)
|
||||||
|
#define CPU_TYPE_STRING CPU_TYPE_STRING_BASE " test release"
|
||||||
|
#else
|
||||||
|
#define CPU_TYPE_STRING CPU_TYPE_STRING_BASE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef void (*LogCStringFunctionProc)(const char *string, unsigned length, BOOL withSyslogBanner);
|
typedef void (*LogCStringFunctionProc)(const char *string, unsigned length, BOOL withSyslogBanner);
|
||||||
typedef LogCStringFunctionProc (*LogCStringFunctionGetterProc)(void);
|
typedef LogCStringFunctionProc (*LogCStringFunctionGetterProc)(void);
|
||||||
typedef void (*LogCStringFunctionSetterProc)(LogCStringFunctionProc);
|
typedef void (*LogCStringFunctionSetterProc)(LogCStringFunctionProc);
|
||||||
@ -70,6 +93,9 @@ static void LoadLogCStringFunctions(void);
|
|||||||
|
|
||||||
static void OONSLogCStringFunction(const char *string, unsigned length, BOOL withSyslogBanner);
|
static void OONSLogCStringFunction(const char *string, unsigned length, BOOL withSyslogBanner);
|
||||||
|
|
||||||
|
static NSString *GetSysCtlString(const char *name);
|
||||||
|
static unsigned long long GetSysCtlInt(const char *name);
|
||||||
|
|
||||||
|
|
||||||
#define kFlushInterval 2.0 // Lower bound on interval between explicit log file flushes.
|
#define kFlushInterval 2.0 // Lower bound on interval between explicit log file flushes.
|
||||||
|
|
||||||
@ -180,6 +206,9 @@ enum
|
|||||||
NSFileManager *fmgr = nil;
|
NSFileManager *fmgr = nil;
|
||||||
NSString *preamble = nil;
|
NSString *preamble = nil;
|
||||||
NSString *versionString = nil;
|
NSString *versionString = nil;
|
||||||
|
NSString *sysModel = nil;
|
||||||
|
unsigned long long sysPhysMem, sysCPUType, sysCPUSubType,
|
||||||
|
sysCPUFrequency, sysCPUCount;
|
||||||
|
|
||||||
// We'll need these for a couple of things.
|
// We'll need these for a couple of things.
|
||||||
bundle = [NSBundle mainBundle];
|
bundle = [NSBundle mainBundle];
|
||||||
@ -277,7 +306,19 @@ enum
|
|||||||
versionString = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
versionString = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||||
if (versionString == nil) versionString = @"<unknown version>";
|
if (versionString == nil) versionString = @"<unknown version>";
|
||||||
|
|
||||||
preamble = [NSString stringWithFormat:@"Opening log for %@ version %@ at %@.\nNote that the contents of the log file can be adjusted by editing logcontrol.plist.\n", appName, versionString, [NSDate date]];
|
// Get some basic system info
|
||||||
|
sysModel = GetSysCtlString("hw.model");
|
||||||
|
sysPhysMem = GetSysCtlInt("hw.physmem");
|
||||||
|
sysCPUType = GetSysCtlInt("hw.cputype");
|
||||||
|
sysCPUSubType = GetSysCtlInt("hw.cpusubtype");
|
||||||
|
sysCPUFrequency = GetSysCtlInt("hw.cpufrequency");
|
||||||
|
sysCPUCount = GetSysCtlInt("hw.logicalcpu");
|
||||||
|
|
||||||
|
preamble = [NSString stringWithFormat:@"Opening log for %@ version %@ [" CPU_TYPE_STRING "] at %@.\n"
|
||||||
|
"Machine type: %@, %llu MiB memory, CPU:%llu.%llux%llu @ %llu MHz\n"
|
||||||
|
"Note that the contents of the log file can be adjusted by editing logcontrol.plist.\n",
|
||||||
|
appName, versionString, [NSDate date],
|
||||||
|
sysModel, (sysPhysMem + (1<<19)) / (1<<20), sysCPUType, sysCPUSubType, sysCPUCount, (sysCPUFrequency + 500000) / 1000000];
|
||||||
[self asyncLogMessage:preamble];
|
[self asyncLogMessage:preamble];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,3 +511,41 @@ static void OONSLogCStringFunction(const char *string, unsigned length, BOOL wit
|
|||||||
OOLogWithFunctionFileAndLine(@"system", NULL, NULL, 0, @"%s", string);
|
OOLogWithFunctionFileAndLine(@"system", NULL, NULL, 0, @"%s", string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static NSString *GetSysCtlString(const char *name)
|
||||||
|
{
|
||||||
|
char *buffer = nil;
|
||||||
|
size_t size = 0;
|
||||||
|
|
||||||
|
// Get size
|
||||||
|
sysctlbyname(name, NULL, &size, NULL, 0);
|
||||||
|
if (size == 0) return nil;
|
||||||
|
|
||||||
|
buffer = alloca(size);
|
||||||
|
if (sysctlbyname(name, buffer, &size, NULL, 0) != 0) return nil;
|
||||||
|
return [NSString stringWithUTF8String:buffer];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned long long GetSysCtlInt(const char *name)
|
||||||
|
{
|
||||||
|
unsigned long long result;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
size = sizeof result;
|
||||||
|
if (sysctlbyname(name, &result, &size, NULL, 0) != 0) return 0;
|
||||||
|
if (size != sizeof result)
|
||||||
|
{
|
||||||
|
if (size == sizeof (int))
|
||||||
|
{
|
||||||
|
result = *(int *)&result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -66,6 +66,14 @@ SOFTWARE.
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef OOLOG_FILE_NAME
|
||||||
|
#ifdef OOLOG_NO_FILE_NAME
|
||||||
|
#define OOLOG_FILE_NAME NULL
|
||||||
|
#else
|
||||||
|
#define OOLOG_FILE_NAME __FILE__
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* OOLOG_SHORT_CIRCUIT:
|
/* OOLOG_SHORT_CIRCUIT:
|
||||||
If nonzero, the test of whether to display a message before evaluating the
|
If nonzero, the test of whether to display a message before evaluating the
|
||||||
@ -95,11 +103,11 @@ SOFTWARE.
|
|||||||
OOLogWillDisplayMessagesInClass().
|
OOLogWillDisplayMessagesInClass().
|
||||||
*/
|
*/
|
||||||
#if OOLOG_SHORT_CIRCUIT
|
#if OOLOG_SHORT_CIRCUIT
|
||||||
#define OOLog(class, format, ...) do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLine(class, OOLOG_FUNCTION_NAME, __FILE__, __LINE__, format, ## __VA_ARGS__); }} while (0)
|
#define OOLog(class, format, ...) do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLine(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, ## __VA_ARGS__); }} while (0)
|
||||||
#define OOLogWithArgmuents(class, format, args) do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLineAndArguments(class, OOLOG_FUNCTION_NAME, __FILE__, __LINE__, format, args); }} while (0)
|
#define OOLogWithArgmuents(class, format, args) do { if (OOLogWillDisplayMessagesInClass(class)) { OOLogWithFunctionFileAndLineAndArguments(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, args); }} while (0)
|
||||||
#else
|
#else
|
||||||
#define OOLog(class, format, ...) OOLogWithFunctionFileAndLine(class, OOLOG_FUNCTION_NAME, __FILE__, __LINE__, format, ## __VA_ARGS__)
|
#define OOLog(class, format, ...) OOLogWithFunctionFileAndLine(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, ## __VA_ARGS__)
|
||||||
#define OOLogWithArgmuents(class, format, args) OOLogWithFunctionFileAndLineAndArguments(class, OOLOG_FUNCTION_NAME, __FILE__, __LINE__, format, args)
|
#define OOLogWithArgmuents(class, format, args) OOLogWithFunctionFileAndLineAndArguments(class, OOLOG_FUNCTION_NAME, OOLOG_FILE_NAME, __LINE__, format, args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass);
|
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass);
|
||||||
|
@ -106,7 +106,6 @@ static BOOL sInited = NO;
|
|||||||
static NSLock *sLock = nil;
|
static NSLock *sLock = nil;
|
||||||
static NSMutableDictionary *sExplicitSettings = nil;
|
static NSMutableDictionary *sExplicitSettings = nil;
|
||||||
static NSMutableDictionary *sDerivedSettingsCache = nil;
|
static NSMutableDictionary *sDerivedSettingsCache = nil;
|
||||||
static NSMutableDictionary *sFileNamesCache = nil;
|
|
||||||
#if USE_INDENT_GLOBALS
|
#if USE_INDENT_GLOBALS
|
||||||
static THREAD_LOCAL unsigned sIndentLevel = 0;
|
static THREAD_LOCAL unsigned sIndentLevel = 0;
|
||||||
static THREAD_LOCAL OOLogIndentStackElement
|
static THREAD_LOCAL OOLogIndentStackElement
|
||||||
@ -134,7 +133,6 @@ static void OOLogInternal_(const char *inFunction, NSString *inFormat, ...);
|
|||||||
// Functions used internally
|
// Functions used internally
|
||||||
static void LoadExplicitSettings(void);
|
static void LoadExplicitSettings(void);
|
||||||
static void LoadExplicitSettingsFromDictionary(NSDictionary *inDict);
|
static void LoadExplicitSettingsFromDictionary(NSDictionary *inDict);
|
||||||
static NSString *AbbreviatedFileName(const char *inName);
|
|
||||||
static id ResolveDisplaySetting(NSString *inMessageClass);
|
static id ResolveDisplaySetting(NSString *inMessageClass);
|
||||||
static id ResolveMetaClassReference(NSString *inMetaClass, NSMutableSet *ioSeenMetaClasses);
|
static id ResolveMetaClassReference(NSString *inMetaClass, NSMutableSet *ioSeenMetaClasses);
|
||||||
|
|
||||||
@ -142,6 +140,12 @@ OOINLINE unsigned GetIndentLevel(void) PURE_FUNC;
|
|||||||
OOINLINE void SetIndentLevel(unsigned level);
|
OOINLINE void SetIndentLevel(unsigned level);
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OOLOG_NO_FILE_NAME
|
||||||
|
static NSMutableDictionary *sFileNamesCache = nil;
|
||||||
|
static NSString *AbbreviatedFileName(const char *inName);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if OOLITE_MAC_OS_X
|
#if OOLITE_MAC_OS_X
|
||||||
#import "OOLogOutputHandler.h"
|
#import "OOLogOutputHandler.h"
|
||||||
#else
|
#else
|
||||||
@ -434,22 +438,24 @@ void OOLogWithFunctionFileAndLineAndArguments(NSString *inMessageClass, const ch
|
|||||||
formattedMessage = [[[NSString alloc] initWithFormat:inFormat arguments:inArguments] autorelease];
|
formattedMessage = [[[NSString alloc] initWithFormat:inFormat arguments:inArguments] autorelease];
|
||||||
|
|
||||||
// Apply various prefix options
|
// Apply various prefix options
|
||||||
if (sShowFunction)
|
#ifndef OOLOG_NO_FILE_NAME
|
||||||
|
if (sShowFileAndLine)
|
||||||
{
|
{
|
||||||
if (sShowFileAndLine)
|
if (sShowFunction)
|
||||||
{
|
{
|
||||||
formattedMessage = [NSString stringWithFormat:@"%s (%@:%u): %@", inFunction, AbbreviatedFileName(inFile), inLine, formattedMessage];
|
formattedMessage = [NSString stringWithFormat:@"%s (%@:%u): %@", inFunction, AbbreviatedFileName(inFile), inLine, formattedMessage];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
formattedMessage = [NSString stringWithFormat:@"%s: %@", inFunction, formattedMessage];
|
formattedMessage = [NSString stringWithFormat:@"%@:%u: %@", AbbreviatedFileName(inFile), inLine, formattedMessage];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (sShowFileAndLine)
|
if (sShowFunction)
|
||||||
{
|
{
|
||||||
formattedMessage = [NSString stringWithFormat:@"%@:%u: %@", AbbreviatedFileName(inFile), inLine, formattedMessage];
|
formattedMessage = [NSString stringWithFormat:@"%s: %@", inFunction, formattedMessage];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,6 +826,7 @@ static void LoadExplicitSettingsFromDictionary(NSDictionary *inDict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OOLOG_NO_FILE_NAME
|
||||||
/* AbbreviatedFileName()
|
/* AbbreviatedFileName()
|
||||||
Map full file paths provided by __FILE__ to more mananagable file names,
|
Map full file paths provided by __FILE__ to more mananagable file names,
|
||||||
with caching.
|
with caching.
|
||||||
@ -842,6 +849,7 @@ static NSString *AbbreviatedFileName(const char *inName)
|
|||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Look up setting for a message class in explicit settings, resolving
|
/* Look up setting for a message class in explicit settings, resolving
|
||||||
|
Loading…
x
Reference in New Issue
Block a user