iOS: devkit log
This commit is contained in:
parent
8a5443b46a
commit
dad9dd7e9e
@ -20,8 +20,55 @@
|
|||||||
// Created by jingpeng.wang on 2020/2/25.
|
// Created by jingpeng.wang on 2020/2/25.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#import "DoricContext.h"
|
||||||
#import "DoricDebugJSEngine.h"
|
#import "DoricDebugJSEngine.h"
|
||||||
#import "DoricJSRemoteExecutor.h"
|
#import "DoricJSRemoteExecutor.h"
|
||||||
|
#import "DoricUtil.h"
|
||||||
|
#import "NSString+JsonString.h"
|
||||||
|
#import "DoricDev.h"
|
||||||
|
|
||||||
|
@interface DoricDebugMonitor : NSObject <DoricMonitorProtocol>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DoricDebugMonitor
|
||||||
|
- (void)onException:(NSException *)exception inContext:(DoricContext *)context {
|
||||||
|
DoricLog(@"DefaultMonitor - source: %@- onException - %@", context.source, exception.reason);
|
||||||
|
NSDictionary *jsonDic = @{
|
||||||
|
@"cmd": @"EXCEPTION",
|
||||||
|
@"data": @{
|
||||||
|
@"source": [context.source stringByReplacingOccurrencesOfString:@".js" withString:@".ts"],
|
||||||
|
@"exception": exception.reason
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NSString *jsonStr = [NSString dc_convertToJsonWithDic:jsonDic];
|
||||||
|
[[DoricDev instance] sendDevCommand:jsonStr];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onLog:(DoricLogType)type message:(NSString *)message {
|
||||||
|
DoricLog(message);
|
||||||
|
|
||||||
|
NSString *typeString = @"DEFAULT";
|
||||||
|
if (type == DoricLogTypeDebug) {
|
||||||
|
typeString = @"DEFAULT";
|
||||||
|
} else if (type == DoricLogTypeWarning) {
|
||||||
|
typeString = @"WARN";
|
||||||
|
} else if (type == DoricLogTypeError) {
|
||||||
|
typeString = @"ERROR";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *jsonDic = @{
|
||||||
|
@"cmd": @"LOG",
|
||||||
|
@"data": @{
|
||||||
|
@"type": typeString,
|
||||||
|
@"message": message
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NSString *jsonStr = [NSString dc_convertToJsonWithDic:jsonDic];
|
||||||
|
[[DoricDev instance] sendDevCommand:jsonStr];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface DoricDebugJSEngine ()
|
@interface DoricDebugJSEngine ()
|
||||||
@end
|
@end
|
||||||
@ -35,6 +82,7 @@ - (instancetype)init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)initJSEngine {
|
- (void)initJSEngine {
|
||||||
|
[self.registry registerMonitor:[DoricDebugMonitor new]];
|
||||||
self.jsExecutor = [[DoricJSRemoteExecutor alloc] init];
|
self.jsExecutor = [[DoricJSRemoteExecutor alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,19 +77,6 @@ + (instancetype)instance {
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface DoricDefaultMonitor : NSObject <DoricMonitorProtocol>
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation DoricDefaultMonitor
|
|
||||||
- (void)onException:(NSException *)exception inContext:(DoricContext *)context {
|
|
||||||
DoricLog(@"DefaultMonitor - source: %@- onException - %@", context.source, exception.reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)onLog:(DoricLogType)type message:(NSString *)message {
|
|
||||||
DoricLog(message);
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface DoricRegistry ()
|
@interface DoricRegistry ()
|
||||||
|
|
||||||
@property(nonatomic, strong) NSMutableDictionary *bundles;
|
@property(nonatomic, strong) NSMutableDictionary *bundles;
|
||||||
@ -113,7 +100,6 @@ - (instancetype)init {
|
|||||||
_envVariables = [NSMutableDictionary new];
|
_envVariables = [NSMutableDictionary new];
|
||||||
[self innerRegister];
|
[self innerRegister];
|
||||||
_monitors = [NSMutableSet new];
|
_monitors = [NSMutableSet new];
|
||||||
[self registerMonitor:[DoricDefaultMonitor new]];
|
|
||||||
[DoricLibraries.instance.libraries enumerateObjectsUsingBlock:^(DoricLibrary *obj, BOOL *stop) {
|
[DoricLibraries.instance.libraries enumerateObjectsUsingBlock:^(DoricLibrary *obj, BOOL *stop) {
|
||||||
[obj load:self];
|
[obj load:self];
|
||||||
}];
|
}];
|
||||||
|
@ -26,6 +26,20 @@
|
|||||||
#import "DoricUtil.h"
|
#import "DoricUtil.h"
|
||||||
#import "DoricBridgeExtension.h"
|
#import "DoricBridgeExtension.h"
|
||||||
#import <sys/utsname.h>
|
#import <sys/utsname.h>
|
||||||
|
#import "DoricContext.h"
|
||||||
|
|
||||||
|
@interface DoricDefaultMonitor : NSObject <DoricMonitorProtocol>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DoricDefaultMonitor
|
||||||
|
- (void)onException:(NSException *)exception inContext:(DoricContext *)context {
|
||||||
|
DoricLog(@"DefaultMonitor - source: %@- onException - %@", context.source, exception.reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onLog:(DoricLogType)type message:(NSString *)message {
|
||||||
|
DoricLog(message);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface DoricJSEngine ()
|
@interface DoricJSEngine ()
|
||||||
@property(nonatomic, strong) NSMutableDictionary *timers;
|
@property(nonatomic, strong) NSMutableDictionary *timers;
|
||||||
@ -59,8 +73,8 @@ - (instancetype)init {
|
|||||||
};
|
};
|
||||||
dispatch_async(_jsQueue, ^() {
|
dispatch_async(_jsQueue, ^() {
|
||||||
self.timers = [[NSMutableDictionary alloc] init];
|
self.timers = [[NSMutableDictionary alloc] init];
|
||||||
[self initJSEngine];
|
|
||||||
self.registry = [[DoricRegistry alloc] init];
|
self.registry = [[DoricRegistry alloc] init];
|
||||||
|
[self initJSEngine];
|
||||||
[self initJSExecutor];
|
[self initJSExecutor];
|
||||||
[self initDoricEnvironment];
|
[self initDoricEnvironment];
|
||||||
});
|
});
|
||||||
@ -69,6 +83,7 @@ - (instancetype)init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)initJSEngine {
|
- (void)initJSEngine {
|
||||||
|
[self.registry registerMonitor:[DoricDefaultMonitor new]];
|
||||||
self.jsExecutor = [DoricJSCoreExecutor new];
|
self.jsExecutor = [DoricJSCoreExecutor new];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user