Oolite
Loading...
Searching...
No Matches
OOLogOutputHandler.h File Reference
import <Foundation/Foundation.h>
Include dependency graph for OOLogOutputHandler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void OOLogOutputHandlerInit (void)
void OOLogOutputHandlerClose (void)
void OOLogOutputHandlerPrint (NSString *string)
NSString * OOLogHandlerGetLogPath (void)
NSString * OOLogHandlerGetLogBasePath (void)
void OOLogOutputHandlerChangeLogFile (NSString *newLogName)
void OOLogOutputHandlerStartLoggingToStdout (void)
void OOLogOutputHandlerStopLoggingToStdout (void)

Function Documentation

◆ OOLogHandlerGetLogBasePath()

NSString * OOLogHandlerGetLogBasePath ( void )

Definition at line 552 of file OOLogOutputHandler.m.

553{
554 static NSString* basePath = nil;
555
556 if (basePath == nil) {
557 const char* logdirEnv = SDL_getenv("OO_LOGSDIR");
558
559 if (logdirEnv) {
560 basePath = [NSString stringWithUTF8String:logdirEnv];
561 } else {
562#if OOLITE_MAC_OS_X
563 // ~/Library
564 basePath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
565#elif OOLITE_LINUX
566 // ~
567 basePath = NSHomeDirectory();
568
569 // ~/.Oolite
570 basePath = [basePath stringByAppendingPathComponent:@".Oolite"];
572 return nil;
573#elif OOLITE_WINDOWS
574 // <Install path>\Oolite
575 basePath = NSHomeDirectory();
576#endif
577
578 // .../Logs
579 basePath = [basePath stringByAppendingPathComponent:@"Logs"];
581 return nil;
582
583#if OOLITE_MAC_OS_X
584 // ~/Library/Logs/Oolite
585 basePath = [basePath stringByAppendingPathComponent:GetAppName()];
587 return nil;
588#endif
589 }
590#if OOLITE_MAC_OS_X
591 ExcludeFromTimeMachine(basePath);
592#endif
593 [basePath retain];
594 }
595
596 return basePath;
597}
static NSString * GetAppName(void)
static BOOL DirectoryExistCreatingIfNecessary(NSString *path)
static void ExcludeFromTimeMachine(NSString *path)
return nil

References DirectoryExistCreatingIfNecessary(), ExcludeFromTimeMachine(), and nil.

Referenced by ResourceManager::diagnosticFileLocation, and GameController::validateMenuItem:.

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

◆ OOLogHandlerGetLogPath()

NSString * OOLogHandlerGetLogPath ( void )

Definition at line 203 of file OOLogOutputHandler.m.

204{
205 return [OOLogHandlerGetLogBasePath() stringByAppendingPathComponent:sLogFileName];
206}
static NSString * sLogFileName
NSString * OOLogHandlerGetLogBasePath(void)

Referenced by OOAsyncLogger::init, OpenLogFile(), and OOAsyncLogger::startLogging.

Here is the caller graph for this function:

◆ OOLogOutputHandlerChangeLogFile()

void OOLogOutputHandlerChangeLogFile ( NSString * newLogName)

Definition at line 208 of file OOLogOutputHandler.m.

209{
210 if (![sLogFileName isEqual:newLogName]) {
211 sLogFileName = [newLogName copy];
212 [sLogger changeFile];
213 }
214}
static OOAsyncLogger * sLogger

References OOAsyncLogger::changeFile, and sLogFileName.

Referenced by SwitchLogFile().

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

◆ OOLogOutputHandlerClose()

void OOLogOutputHandlerClose ( void )

Definition at line 147 of file OOLogOutputHandler.m.

148{
149 if (sInited) {
150 sWriteToStderr = YES;
151 sInited = NO;
152
153 [sLogger endLogging];
155
156#if OOLITE_MAC_OS_X
160 }
161#elif GNUSTEP_BASE_LIBRARY
162 NSRecursiveLock* lock = GSLogLock();
163 [lock lock];
164 _NSLog_printf_handler = NULL;
165 [lock unlock];
166#endif
167 }
168}
static BOOL sInited
Definition OOCPUInfo.m:56
#define DESTROY(x)
static LogCStringFunctionSetterProc _NSSetLogCStringFunction
static LogCStringFunctionProc sDefaultLogCStringFunction
static BOOL sWriteToStderr

References _NSSetLogCStringFunction, DESTROY, OOAsyncLogger::endLogging, sDefaultLogCStringFunction, sInited, sLogger, and sWriteToStderr.

Referenced by OOLoggingTerminate(), and OOLogOutputHandlerInit().

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

◆ OOLogOutputHandlerInit()

void OOLogOutputHandlerInit ( void )

Definition at line 111 of file OOLogOutputHandler.m.

112{
113 if (sInited)
114 return;
115
116#if SET_CRASH_REPORTER_INFO
118#endif
119
120 sLogger = [[OOAsyncLogger alloc] init];
121 sInited = YES;
122
123 if (sLogger != nil) {
124 sWriteToStderr = [[NSUserDefaults standardUserDefaults] boolForKey:@"logging-echo-to-stderr"];
125 } else {
126 sWriteToStderr = YES;
127 }
128
129#if OOLITE_MAC_OS_X
131 if (_NSSetLogCStringFunction != NULL) {
134 } else {
135 OOLog(@"logging.nsLogFilter.install.failed", @"Failed to install NSLog() filter; system messages will not be logged in log file.");
136 }
137#elif GNUSTEP_BASE_LIBRARY
138 NSRecursiveLock* lock = GSLogLock();
139 [lock lock];
140 _NSLog_printf_handler = OONSLogPrintfHandler;
141 [lock unlock];
142#endif
143
145}
void OOLogOutputHandlerClose(void)
static LogCStringFunctionGetterProc _NSLogCStringFunction
static void InitCrashReporterInfo(void)
static void LoadLogCStringFunctions(void)
static void OONSLogCStringFunction(const char *string, unsigned length, BOOL withSyslogBanner)
#define OOLog(class, format,...)
Definition OOLogging.h:84

References _NSLogCStringFunction, _NSSetLogCStringFunction, InitCrashReporterInfo(), LoadLogCStringFunctions(), nil, OOLog, OOLogOutputHandlerClose(), OONSLogCStringFunction(), sDefaultLogCStringFunction, sInited, sLogger, and sWriteToStderr.

Referenced by OOLoggingInit().

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

◆ OOLogOutputHandlerPrint()

void OOLogOutputHandlerPrint ( NSString * string)

Definition at line 179 of file OOLogOutputHandler.m.

180{
181 if (sInited && sLogger != nil && !sWriteToStdout)
182 [sLogger asyncLogMessage:string];
183
184 BOOL doCStringStuff = sWriteToStderr || sWriteToStdout;
185#if SET_CRASH_REPORTER_INFO
186 doCStringStuff = doCStringStuff || sCrashReporterInfoAvailable;
187#endif
188
189 if (doCStringStuff) {
190 const char* cStr = [[string stringByAppendingString:@"\n"] UTF8String];
191 if (sWriteToStdout)
192 fputs(cStr, stdout);
193 else if (sWriteToStderr)
194 fputs(cStr, stderr);
195
196#if SET_CRASH_REPORTER_INFO
199#endif
200 }
201}
static void SetCrashReporterInfo(const char *info)
static BOOL sCrashReporterInfoAvailable
static BOOL sWriteToStdout

References OOAsyncLogger::asyncLogMessage:, nil, sCrashReporterInfoAvailable, SetCrashReporterInfo(), sInited, sLogger, sWriteToStderr, and sWriteToStdout.

Referenced by OOLogInsertMarker(), OOLogInternal_(), and OOLogWithFunctionFileAndLineAndArguments().

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

◆ OOLogOutputHandlerStartLoggingToStdout()

void OOLogOutputHandlerStartLoggingToStdout ( void )

Definition at line 170 of file OOLogOutputHandler.m.

171{
172 sWriteToStdout = true;
173}

References sWriteToStdout.

◆ OOLogOutputHandlerStopLoggingToStdout()

void OOLogOutputHandlerStopLoggingToStdout ( void )

Definition at line 174 of file OOLogOutputHandler.m.

175{
176 sWriteToStdout = false;
177}

References sWriteToStdout.