Oolite 1.91.0.7644-241112-7f5034b
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()

static NSString * OOLogHandlerGetLogBasePath ( void )

Definition at line 305 of file OODockTilePlugIn.m.

306{
307 static NSString *basePath = nil;
308
309 if (basePath == nil)
310 {
311 // ~/Library
312 basePath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
313 basePath = [basePath stringByAppendingPathComponent:@"Logs"];
314 basePath = [basePath stringByAppendingPathComponent:@"Oolite"];
315
316 BOOL exists, directory;
317 NSFileManager *fmgr = [NSFileManager defaultManager];
318
319 exists = [fmgr fileExistsAtPath:basePath isDirectory:&directory];
320 if (exists)
321 {
322 if (!directory)
323 {
324 basePath = nil;
325 }
326 }
327 else
328 {
329 if (![fmgr createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:nil error:NULL])
330 {
331 basePath = nil;
332 }
333 }
334
335 [basePath retain];
336 }
337
338 return basePath;
339}
return nil

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

+ Here is the call graph for this function:

◆ OOLogHandlerGetLogPath()

NSString * OOLogHandlerGetLogPath ( void )

Definition at line 220 of file OOLogOutputHandler.m.

221{
222 return [OOLogHandlerGetLogBasePath() stringByAppendingPathComponent:sLogFileName];
223}
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 226 of file OOLogOutputHandler.m.

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

162{
163 if (sInited)
164 {
165 sWriteToStderr = YES;
166 sInited = NO;
167
168 [sLogger endLogging];
170
171#if OOLITE_MAC_OS_X
173 {
176 }
177#elif GNUSTEP
178 NSRecursiveLock *lock = GSLogLock();
179 [lock lock];
180 _NSLog_printf_handler = NULL;
181 [lock unlock];
182#endif
183 }
184}
#define DESTROY(x)
Definition OOCocoa.h:77
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 119 of file OOLogOutputHandler.m.

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

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

187{
188 sWriteToStdout = true;
189}

References sWriteToStdout.

◆ OOLogOutputHandlerStopLoggingToStdout()

void OOLogOutputHandlerStopLoggingToStdout ( void )

Definition at line 190 of file OOLogOutputHandler.m.

191{
192 sWriteToStdout = false;
193}

References sWriteToStdout.