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 608 of file OOLogOutputHandler.m.

609{
610 static NSString *basePath = nil;
611
612 if (basePath == nil)
613 {
614 const char *logdirEnv = SDL_getenv("OO_LOGSDIR");
615
616 if (logdirEnv)
617 {
618 basePath = [NSString stringWithUTF8String:logdirEnv];
619 }
620 else
621 {
622#if OOLITE_MAC_OS_X
623 // ~/Library
624 basePath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
625#elif OOLITE_LINUX
626 // ~
627 basePath = NSHomeDirectory();
628
629 // ~/.Oolite
630 basePath = [basePath stringByAppendingPathComponent:@".Oolite"];
631 if (!DirectoryExistCreatingIfNecessary(basePath)) return nil;
632#elif OOLITE_WINDOWS
633 // <Install path>\Oolite
634 basePath = NSHomeDirectory();
635#endif
636
637 // .../Logs
638 basePath = [basePath stringByAppendingPathComponent:@"Logs"];
639 if (!DirectoryExistCreatingIfNecessary(basePath)) return nil;
640
641#if OOLITE_MAC_OS_X
642 // ~/Library/Logs/Oolite
643 basePath = [basePath stringByAppendingPathComponent:GetAppName()];
644 if (!DirectoryExistCreatingIfNecessary(basePath)) return nil;
645#endif
646 }
647#if OOLITE_MAC_OS_X
648 ExcludeFromTimeMachine(basePath);
649#endif
650 [basePath retain];
651 }
652
653 return basePath;
654}
static NSString * GetAppName(void)
static BOOL DirectoryExistCreatingIfNecessary(NSString *path)
static void ExcludeFromTimeMachine(NSString *path)
return nil

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

+ Here is the call graph for this function:

◆ OOLogHandlerGetLogPath()

NSString * OOLogHandlerGetLogPath ( void  )

Definition at line 221 of file OOLogOutputHandler.m.

222{
223 return [OOLogHandlerGetLogBasePath() stringByAppendingPathComponent:sLogFileName];
224}
static NSString * sLogFileName
NSString * OOLogHandlerGetLogBasePath(void)

Referenced by OOOXPVerifier(OOPrivate)::buildDependencyGraph.

+ Here is the caller graph for this function:

◆ OOLogOutputHandlerChangeLogFile()

void OOLogOutputHandlerChangeLogFile ( NSString *  newLogName)

Definition at line 227 of file OOLogOutputHandler.m.

228{
229 if (![sLogFileName isEqual:newLogName])
230 {
231 sLogFileName = [newLogName copy];
232 [sLogger changeFile];
233 }
234}
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 162 of file OOLogOutputHandler.m.

163{
164 if (sInited)
165 {
166 sWriteToStderr = YES;
167 sInited = NO;
168
169 [sLogger endLogging];
171
172#if OOLITE_MAC_OS_X
174 {
177 }
178#elif GNUSTEP_BASE_LIBRARY
179 NSRecursiveLock *lock = GSLogLock();
180 [lock lock];
181 _NSLog_printf_handler = NULL;
182 [lock unlock];
183#endif
184 }
185}
#define DESTROY(x)
Definition OOCocoa.h:75
static LogCStringFunctionSetterProc _NSSetLogCStringFunction
static LogCStringFunctionProc sDefaultLogCStringFunction
static BOOL sWriteToStderr
static BOOL sInited

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 120 of file OOLogOutputHandler.m.

121{
122 if (sInited) return;
123
124#if SET_CRASH_REPORTER_INFO
126#endif
127
128 sLogger = [[OOAsyncLogger alloc] init];
129 sInited = YES;
130
131 if (sLogger != nil)
132 {
133 sWriteToStderr = [[NSUserDefaults standardUserDefaults] boolForKey:@"logging-echo-to-stderr"];
134 }
135 else
136 {
137 sWriteToStderr = YES;
138 }
139
140#if OOLITE_MAC_OS_X
142 if (_NSSetLogCStringFunction != NULL)
143 {
146 }
147 else
148 {
149 OOLog(@"logging.nsLogFilter.install.failed", @"Failed to install NSLog() filter; system messages will not be logged in log file.");
150 }
151#elif GNUSTEP_BASE_LIBRARY
152 NSRecursiveLock *lock = GSLogLock();
153 [lock lock];
154 _NSLog_printf_handler = OONSLogPrintfHandler;
155 [lock unlock];
156#endif
157
159}
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:88

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 196 of file OOLogOutputHandler.m.

197{
198 if (sInited && sLogger != nil && !sWriteToStdout) [sLogger asyncLogMessage:string];
199
200 BOOL doCStringStuff = sWriteToStderr || sWriteToStdout;
201#if SET_CRASH_REPORTER_INFO
202 doCStringStuff = doCStringStuff || sCrashReporterInfoAvailable;
203#endif
204
205 if (doCStringStuff)
206 {
207 const char *cStr = [[string stringByAppendingString:@"\n"] UTF8String];
208 if (sWriteToStdout)
209 fputs(cStr, stdout);
210 else if (sWriteToStderr)
211 fputs(cStr, stderr);
212
213#if SET_CRASH_REPORTER_INFO
215#endif
216 }
217
218}
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 187 of file OOLogOutputHandler.m.

188{
189 sWriteToStdout = true;
190}

References sWriteToStdout.

◆ OOLogOutputHandlerStopLoggingToStdout()

void OOLogOutputHandlerStopLoggingToStdout ( void  )

Definition at line 191 of file OOLogOutputHandler.m.

192{
193 sWriteToStdout = false;
194}

References sWriteToStdout.