diff --git a/platform-darwin/Source/MPAppDelegate_Shared.m b/platform-darwin/Source/MPAppDelegate_Shared.m index cf4eaaf7..f45e77f8 100644 --- a/platform-darwin/Source/MPAppDelegate_Shared.m +++ b/platform-darwin/Source/MPAppDelegate_Shared.m @@ -31,6 +31,35 @@ @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 static MPAppDelegate_Shared *instance; @@ -45,6 +74,16 @@ static MPAppDelegate_Shared *instance; if (!(self = instance = [super init])) 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]; [model kc_generateOrderedSetAccessors]; self.storeCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.m b/platform-darwin/Source/Mac/MPMacAppDelegate.m index 0570365c..27f06f43 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.m +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.m @@ -39,14 +39,7 @@ static EventHotKeyID MPLockHotKey = { .signature = 'lock', .id = 1 }; + (void)initialize { - static dispatch_once_t once = 0; - dispatch_once( &once, ^{ - [MPMacConfig get]; - -#ifdef DEBUG - [PearlLogger get].printLevel = PearlLogLevelDebug; //Trace; -#endif - } ); + [MPMacConfig get]; } static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData) { @@ -98,7 +91,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven SentryLevel sentryLevel = kSentryLevelInfo; switch (message.level) { case PearlLogLevelTrace: - sentryLevel = kSentryLevelDebug; + sentryLevel = kSentryLevelNone; break; case PearlLogLevelDebug: sentryLevel = kSentryLevelDebug; diff --git a/platform-darwin/Source/iOS/MPiOSAppDelegate.m b/platform-darwin/Source/iOS/MPiOSAppDelegate.m index 6561e1a9..a3093436 100644 --- a/platform-darwin/Source/iOS/MPiOSAppDelegate.m +++ b/platform-darwin/Source/iOS/MPiOSAppDelegate.m @@ -33,50 +33,11 @@ @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 + (void)initialize { - static dispatch_once_t once = 0; - 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 ); - } ); + [MPiOSConfig get]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {