Cross-platform translation of mpw logs into Pearl.
This commit is contained in:
parent
c62ff63718
commit
8e15be21ab
@ -31,6 +31,35 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
MPLogSink mpw_log_sink_pearl;
|
||||||
|
void mpw_log_sink_pearl(const MPLogEvent *record) {
|
||||||
|
|
||||||
|
PearlLogLevel level = PearlLogLevelInfo;
|
||||||
|
switch (record->level) {
|
||||||
|
case LogLevelTrace:
|
||||||
|
level = PearlLogLevelTrace;
|
||||||
|
break;
|
||||||
|
case LogLevelDebug:
|
||||||
|
level = PearlLogLevelDebug;
|
||||||
|
break;
|
||||||
|
case LogLevelInfo:
|
||||||
|
level = PearlLogLevelInfo;
|
||||||
|
break;
|
||||||
|
case LogLevelWarning:
|
||||||
|
level = PearlLogLevelWarn;
|
||||||
|
break;
|
||||||
|
case LogLevelError:
|
||||||
|
level = PearlLogLevelError;
|
||||||
|
break;
|
||||||
|
case LogLevelFatal:
|
||||||
|
level = PearlLogLevelFatal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[PearlLogger get] inFile:[@(record->file) lastPathComponent] atLine:record->line fromFunction:@(record->function)
|
||||||
|
withLevel:level text:@(record->message)];
|
||||||
|
}
|
||||||
|
|
||||||
@implementation MPAppDelegate_Shared
|
@implementation MPAppDelegate_Shared
|
||||||
|
|
||||||
static MPAppDelegate_Shared *instance;
|
static MPAppDelegate_Shared *instance;
|
||||||
@ -45,6 +74,16 @@ static MPAppDelegate_Shared *instance;
|
|||||||
if (!(self = instance = [super init]))
|
if (!(self = instance = [super init]))
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
|
[PearlLogger get].historyLevel = PearlLogLevelInfo;
|
||||||
|
#ifdef DEBUG
|
||||||
|
[PearlLogger get].printLevel = PearlLogLevelDebug;
|
||||||
|
#else
|
||||||
|
[PearlLogger get].printLevel = PearlLogLevelInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mpw_verbosity = LogLevelTrace;
|
||||||
|
mpw_log_sink_register( &mpw_log_sink_pearl );
|
||||||
|
|
||||||
NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:nil];
|
NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:nil];
|
||||||
[model kc_generateOrderedSetAccessors];
|
[model kc_generateOrderedSetAccessors];
|
||||||
self.storeCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
|
self.storeCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
|
||||||
|
@ -39,14 +39,7 @@ static EventHotKeyID MPLockHotKey = { .signature = 'lock', .id = 1 };
|
|||||||
|
|
||||||
+ (void)initialize {
|
+ (void)initialize {
|
||||||
|
|
||||||
static dispatch_once_t once = 0;
|
[MPMacConfig get];
|
||||||
dispatch_once( &once, ^{
|
|
||||||
[MPMacConfig get];
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
[PearlLogger get].printLevel = PearlLogLevelDebug; //Trace;
|
|
||||||
#endif
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData) {
|
static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData) {
|
||||||
@ -98,7 +91,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
|||||||
SentryLevel sentryLevel = kSentryLevelInfo;
|
SentryLevel sentryLevel = kSentryLevelInfo;
|
||||||
switch (message.level) {
|
switch (message.level) {
|
||||||
case PearlLogLevelTrace:
|
case PearlLogLevelTrace:
|
||||||
sentryLevel = kSentryLevelDebug;
|
sentryLevel = kSentryLevelNone;
|
||||||
break;
|
break;
|
||||||
case PearlLogLevelDebug:
|
case PearlLogLevelDebug:
|
||||||
sentryLevel = kSentryLevelDebug;
|
sentryLevel = kSentryLevelDebug;
|
||||||
|
@ -33,50 +33,11 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
MPLogSink mpw_log_sink_pearl;
|
|
||||||
void mpw_log_sink_pearl(const MPLogEvent *record) {
|
|
||||||
|
|
||||||
PearlLogLevel level = PearlLogLevelInfo;
|
|
||||||
switch (record->level) {
|
|
||||||
case LogLevelTrace:
|
|
||||||
level = PearlLogLevelDebug;
|
|
||||||
break;
|
|
||||||
case LogLevelDebug:
|
|
||||||
level = PearlLogLevelDebug;
|
|
||||||
break;
|
|
||||||
case LogLevelInfo:
|
|
||||||
level = PearlLogLevelInfo;
|
|
||||||
break;
|
|
||||||
case LogLevelWarning:
|
|
||||||
level = PearlLogLevelWarn;
|
|
||||||
break;
|
|
||||||
case LogLevelError:
|
|
||||||
level = PearlLogLevelError;
|
|
||||||
break;
|
|
||||||
case LogLevelFatal:
|
|
||||||
level = PearlLogLevelFatal;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[PearlLogger get] inFile:[@(record->file) lastPathComponent] atLine:record->line fromFunction:@(record->function)
|
|
||||||
withLevel:level text:@(record->message)];
|
|
||||||
}
|
|
||||||
|
|
||||||
@implementation MPiOSAppDelegate
|
@implementation MPiOSAppDelegate
|
||||||
|
|
||||||
+ (void)initialize {
|
+ (void)initialize {
|
||||||
|
|
||||||
static dispatch_once_t once = 0;
|
[MPiOSConfig get];
|
||||||
dispatch_once( &once, ^{
|
|
||||||
[PearlLogger get].printLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelDebug: PearlLogLevelInfo;
|
|
||||||
[PearlLogger get].historyLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelTrace: PearlLogLevelInfo;
|
|
||||||
#ifdef DEBUG
|
|
||||||
[PearlLogger get].printLevel = PearlLogLevelDebug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mpw_verbosity = LogLevelTrace;
|
|
||||||
mpw_log_sink_register( &mpw_log_sink_pearl );
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
|
Loading…
Reference in New Issue
Block a user