blob: 17aeb907beb5698c55b306803e5f98f20f4f171c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
//
// Copyright (c) 2013 Ford Motor Company
//
#import "SDLDebugTool.h"
#import "SDLSiphonServer.h"
#import "SDLVersion.h"
#define LOG_INFO_ENABLED
#define LOG_ERROR_ENABLED
static NSMutableArray* debugToolConsoleList = nil;
@implementation SDLDebugTool
+(NSMutableArray*) getConsoleList {
if (debugToolConsoleList == nil) {
debugToolConsoleList = [[NSMutableArray alloc] initWithCapacity:2];
}
return debugToolConsoleList;
}
+(void) addConsole:(NSObject<SDLDebugToolConsole>*) aConsole {
[[SDLDebugTool getConsoleList] addObject:aConsole];
}
+(void) removeConsole:(NSObject<SDLDebugToolConsole>*) aConsole {
[[SDLDebugTool getConsoleList] removeObject:aConsole];
}
+(void) logInfo:(NSString*) sdlt, ... {
NSString* toOutRaw = nil;
va_list args;
va_start(args, sdlt);
toOutRaw = [[NSString alloc] initWithFormat:sdlt arguments:args];
NSMutableString *toOut = [[NSMutableString alloc] initWithFormat:@"SDLDebugTool: "];
[toOut appendString:toOutRaw];
[toOutRaw release];
va_end(args);
[SDLSiphonServer init];
bool dataLogged = [SDLSiphonServer _siphonNSLogData:toOut];
#ifdef LOG_INFO_ENABLED
if(!dataLogged){
NSLog(@"%@", toOut);
}
#endif
for (NSObject<SDLDebugToolConsole>* console in debugToolConsoleList) {
[console logInfo:toOut];
}
[toOut release];
}
+(void) logException:(NSException*) ex withMessage:(NSString*) sdlt, ... {
NSString* toOutRaw = nil;
va_list args;
va_start(args, sdlt);
toOutRaw = [[NSString alloc] initWithFormat:sdlt arguments:args];
NSMutableString *toOut = [[NSMutableString alloc] initWithFormat:@"%@: ", VERSION_STRING];
[toOut appendString:toOutRaw];
[toOutRaw release];
va_end(args);
[SDLSiphonServer init];
bool dataLogged = [SDLSiphonServer _siphonNSLogData:toOut];
if (dataLogged) {
dataLogged = [SDLSiphonServer _siphonNSLogData:[ex reason]];
} // end-if
#ifdef LOG_ERROR_ENABLED
if (!dataLogged) {
NSLog(@"%@: %@", toOut, ex);
}
#endif
for (NSObject<SDLDebugToolConsole>* console in debugToolConsoleList) {
[console logException:ex withMessage:toOut];
}
[toOut release];
}
@end
|