@wutiange/log-listener-plugin 2.0.1-alpha.3 → 2.0.1-alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -201
- package/README.md +163 -163
- package/dist/src/__tests__/Server.test.js +4 -4
- package/dist/src/__tests__/Server.test.js.map +1 -1
- package/dist/src/__tests__/console.test.d.ts +1 -0
- package/dist/src/__tests__/console.test.js +29 -0
- package/dist/src/__tests__/console.test.js.map +1 -0
- package/dist/src/__tests__/utils.test.js +5 -1
- package/dist/src/__tests__/utils.test.js.map +1 -1
- package/dist/src/common.d.ts +1 -1
- package/dist/src/common.js +1 -1
- package/dist/src/common.js.map +1 -1
- package/dist/src/logPlugin.js +9 -10
- package/dist/src/logPlugin.js.map +1 -1
- package/dist/src/server.d.ts +21 -0
- package/dist/src/{Server.js → server.js} +47 -31
- package/dist/src/server.js.map +1 -0
- package/dist/src/utils.js +4 -4
- package/dist/src/utils.js.map +1 -1
- package/index.ts +3 -3
- package/package.json +59 -59
- package/src/HTTPInterceptor.ts +339 -339
- package/src/Server.ts +178 -167
- package/src/__mocks__/react-native/Libraries/Blob/FileReader.js +44 -44
- package/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js +39 -39
- package/src/__tests__/HTTPInterceptor.test.ts +322 -322
- package/src/__tests__/Server.test.ts +149 -149
- package/src/__tests__/utils.test.ts +113 -112
- package/src/common.ts +69 -69
- package/src/logPlugin.ts +223 -224
- package/src/logger.ts +14 -14
- package/src/utils.ts +112 -112
- package/tsconfig.json +26 -26
- package/dist/src/Server.d.ts +0 -20
- package/dist/src/Server.js.map +0 -1
package/README.md
CHANGED
@@ -1,163 +1,163 @@
|
|
1
|
-
# log-listener-plugin
|
2
|
-
[![Dependencies](https://img.shields.io/badge/dependencies-none-green)](https://www.npmjs.com/package/@wutiange/log-listener-plugin?activeTab=dependencies)
|
3
|
-
[![npm](https://img.shields.io/npm/v/@wutiange/log-listener-plugin)](https://www.npmjs.com/package/@wutiange/log-listener-plugin)
|
4
|
-
[![npm downloads](https://img.shields.io/npm/dm/@wutiange/log-listener-plugin)](https://www.npmjs.com/package/@wutiange/log-listener-plugin)
|
5
|
-
[![License](https://img.shields.io/npm/l/@wutiange/log-listener-plugin)](./LICENSE)
|
6
|
-
|
7
|
-
中文 | [English](./docs/README_EN.md)
|
8
|
-
|
9
|
-
要想正常使用 [log-record](https://github.com/wutiange/log-record) 客户端来收集日志,方便排查问题,那么就需要把这个插件安装到项目中。
|
10
|
-
|
11
|
-
## 1. 安装
|
12
|
-
|
13
|
-
使用 npm 安装
|
14
|
-
|
15
|
-
```bash
|
16
|
-
npm install @wutiange/log-listener-plugin
|
17
|
-
```
|
18
|
-
|
19
|
-
使用 yarn 安装
|
20
|
-
|
21
|
-
```bash
|
22
|
-
yarn add @wutiange/log-listener-plugin
|
23
|
-
```
|
24
|
-
|
25
|
-
## 2. 使用
|
26
|
-
|
27
|
-
在你需要开始记录日志的地方,调用下面的代码即可。
|
28
|
-
|
29
|
-
### 2.1 基于自我发现的使用
|
30
|
-
|
31
|
-
先安装 react-native-zeroconf ,这个的目的是发现局域网内可用的日志系统。
|
32
|
-
|
33
|
-
```bash
|
34
|
-
yarn add react-native-zeroconf
|
35
|
-
# 或
|
36
|
-
npm install react-native-zeroconf
|
37
|
-
```
|
38
|
-
|
39
|
-
具体安装步骤请移步:[react-native-zeroconf](https://www.npmjs.com/package/react-native-zeroconf) ,请不要忽略这行,因为要想使用这个还需要做一些必要的步骤,我也把这些复制到下面,以免被人忽略。
|
40
|
-
|
41
|
-
For Android please ensure your manifest is requesting all necessary permissions.
|
42
|
-
|
43
|
-
```xml
|
44
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
45
|
-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
46
|
-
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
|
47
|
-
```
|
48
|
-
|
49
|
-
IOS 14 requires you to specify the services you want to scan for and a description for what you're using them.
|
50
|
-
|
51
|
-
In your `info.plist` add the following strings:
|
52
|
-
|
53
|
-
```plist
|
54
|
-
<key>NSBonjourServices</key>
|
55
|
-
<array>
|
56
|
-
<string>_http._tcp</string>
|
57
|
-
</array>
|
58
|
-
<key>NSLocalNetworkUsageDescription</key>
|
59
|
-
<string>Access nearby Log Records to view logs</string>
|
60
|
-
```
|
61
|
-
|
62
|
-
接下来只需要在项目中找个合适的位置,一般是在 App.js 中调用。
|
63
|
-
|
64
|
-
```ts
|
65
|
-
import logger from '@wutiange/log-listener-plugin';
|
66
|
-
// 启动日志记录
|
67
|
-
logger.config({isAuto: true});
|
68
|
-
```
|
69
|
-
|
70
|
-
### 2.2 基于手动设置的方式使用
|
71
|
-
|
72
|
-
```ts
|
73
|
-
import logger from '@wutiange/log-listener-plugin';
|
74
|
-
// 填写日志服务器的地址,如果你使用自我发现功能,那么这一步可以省略
|
75
|
-
logger.config({isAuto: true, testUrl: 'http://127.0.0.1'});
|
76
|
-
```
|
77
|
-
|
78
|
-
### 2.3 设置基本数据
|
79
|
-
|
80
|
-
设置基础数据,一般数据从 react-native-device-info 中获取,如果你没有特殊的可以不要调用,内部会根据你安装的 react-native-device-info 自动获取基础数据。这些基础数据的目的是为了过滤数据,不是必须的。
|
81
|
-
|
82
|
-
```ts
|
83
|
-
logger.config({
|
84
|
-
baseData: {
|
85
|
-
Brand: DeviceInfo.getBrand(),
|
86
|
-
Model: DeviceInfo.getModel(),
|
87
|
-
AppVersion: DeviceInfo.getVersion(),
|
88
|
-
Carrier: DeviceInfo.getCarrierSync(),
|
89
|
-
Manufacturer: DeviceInfo.getManufacturerSync(),
|
90
|
-
SystemName: DeviceInfo.getSystemName(),
|
91
|
-
}
|
92
|
-
});
|
93
|
-
```
|
94
|
-
|
95
|
-
### 2.4 单独记录和停止所有记录
|
96
|
-
|
97
|
-
尽量不要使用以下 API ,这些 API 也没必要,这些数据都只会保存到你打开的日志系统中,所以都是能收集啥就都收集啥,目的是方便排查问题。
|
98
|
-
|
99
|
-
```ts
|
100
|
-
// 只抓取日志
|
101
|
-
logger.startRecordLog();
|
102
|
-
// 只抓取网络日志
|
103
|
-
logger.startRecordNetwork();
|
104
|
-
|
105
|
-
// 停止日志记录,会同时停止日志和网络
|
106
|
-
logger.unAuto();
|
107
|
-
```
|
108
|
-
|
109
|
-
### 2.5 其他使用说明
|
110
|
-
|
111
|
-
如果你希望杀死手机后下次进来仍然能记住之前保存的 IP 地址,那么你可以考虑安装:
|
112
|
-
|
113
|
-
```bash
|
114
|
-
yarn add @react-native-async-storage/async-storage
|
115
|
-
```
|
116
|
-
|
117
|
-
如果你本地有安装其他的 storage ,那么你可以手动设置:
|
118
|
-
|
119
|
-
```ts
|
120
|
-
logger.config({
|
121
|
-
storage: // 你的 storage ;或者你自己写的,只要遵循 getItem 和 setItem 接口规范即可
|
122
|
-
})
|
123
|
-
```
|
124
|
-
|
125
|
-
现在把若干配置相关的都放到了 config 中,以此来简化配置,配置的每一项都是可选的:
|
126
|
-
|
127
|
-
```ts
|
128
|
-
type Options = {
|
129
|
-
/**
|
130
|
-
* storage 用于存储已设置的日志系统的 url
|
131
|
-
* @default @react-native-async-storage/async-storage
|
132
|
-
*/
|
133
|
-
storage?: Storage
|
134
|
-
/**
|
135
|
-
* 设置上传日志的超时时间,单位为毫秒
|
136
|
-
* @default 3000
|
137
|
-
*/
|
138
|
-
timeout?: number
|
139
|
-
/**
|
140
|
-
* 日志系统的url
|
141
|
-
*/
|
142
|
-
testUrl?: string
|
143
|
-
/**
|
144
|
-
* 是否自动开启日志记录
|
145
|
-
* @default false
|
146
|
-
*/
|
147
|
-
isAuto?: boolean
|
148
|
-
/**
|
149
|
-
* 设置日志系统的基础数据,这些数据会自动添加到每条日志中
|
150
|
-
*/
|
151
|
-
baseData?: Record<string, any>
|
152
|
-
}
|
153
|
-
```
|
154
|
-
|
155
|
-
这是 config 每一项的说明。
|
156
|
-
|
157
|
-
## 3. 其他重要说明
|
158
|
-
|
159
|
-
1. 如果你使用的自我发现模式,那么要保证你的手机和 log-record 客户端在同一个局域网下。
|
160
|
-
1. 在配置 baseUrl 的时候,必须填写的是 [log-record](https://github.com/wutiange/log-record) 的地址,也就是你在什么电脑打开的 log-record 客户端,那么这里添加的就是对应电脑的 ip 地址。集成这个插件的 app 端要保证跟 log-record 客户端在同一个局域网下。
|
161
|
-
1. 如果你不知道日志系统的 IP ,可以在日志系统的 `设置 > 链接说明(需要版本大于1.0.9)` 中找到,如下图所示:
|
162
|
-
|
163
|
-
![](
|
1
|
+
# log-listener-plugin
|
2
|
+
[![Dependencies](https://img.shields.io/badge/dependencies-none-green)](https://www.npmjs.com/package/@wutiange/log-listener-plugin?activeTab=dependencies)
|
3
|
+
[![npm](https://img.shields.io/npm/v/@wutiange/log-listener-plugin)](https://www.npmjs.com/package/@wutiange/log-listener-plugin)
|
4
|
+
[![npm downloads](https://img.shields.io/npm/dm/@wutiange/log-listener-plugin)](https://www.npmjs.com/package/@wutiange/log-listener-plugin)
|
5
|
+
[![License](https://img.shields.io/npm/l/@wutiange/log-listener-plugin)](./LICENSE)
|
6
|
+
|
7
|
+
中文 | [English](./docs/README_EN.md)
|
8
|
+
|
9
|
+
要想正常使用 [log-record](https://github.com/wutiange/log-record) 客户端来收集日志,方便排查问题,那么就需要把这个插件安装到项目中。
|
10
|
+
|
11
|
+
## 1. 安装
|
12
|
+
|
13
|
+
使用 npm 安装
|
14
|
+
|
15
|
+
```bash
|
16
|
+
npm install @wutiange/log-listener-plugin
|
17
|
+
```
|
18
|
+
|
19
|
+
使用 yarn 安装
|
20
|
+
|
21
|
+
```bash
|
22
|
+
yarn add @wutiange/log-listener-plugin
|
23
|
+
```
|
24
|
+
|
25
|
+
## 2. 使用
|
26
|
+
|
27
|
+
在你需要开始记录日志的地方,调用下面的代码即可。
|
28
|
+
|
29
|
+
### 2.1 基于自我发现的使用
|
30
|
+
|
31
|
+
先安装 react-native-zeroconf ,这个的目的是发现局域网内可用的日志系统。
|
32
|
+
|
33
|
+
```bash
|
34
|
+
yarn add react-native-zeroconf
|
35
|
+
# 或
|
36
|
+
npm install react-native-zeroconf
|
37
|
+
```
|
38
|
+
|
39
|
+
具体安装步骤请移步:[react-native-zeroconf](https://www.npmjs.com/package/react-native-zeroconf) ,请不要忽略这行,因为要想使用这个还需要做一些必要的步骤,我也把这些复制到下面,以免被人忽略。
|
40
|
+
|
41
|
+
For Android please ensure your manifest is requesting all necessary permissions.
|
42
|
+
|
43
|
+
```xml
|
44
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
45
|
+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
46
|
+
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
|
47
|
+
```
|
48
|
+
|
49
|
+
IOS 14 requires you to specify the services you want to scan for and a description for what you're using them.
|
50
|
+
|
51
|
+
In your `info.plist` add the following strings:
|
52
|
+
|
53
|
+
```plist
|
54
|
+
<key>NSBonjourServices</key>
|
55
|
+
<array>
|
56
|
+
<string>_http._tcp</string>
|
57
|
+
</array>
|
58
|
+
<key>NSLocalNetworkUsageDescription</key>
|
59
|
+
<string>Access nearby Log Records to view logs</string>
|
60
|
+
```
|
61
|
+
|
62
|
+
接下来只需要在项目中找个合适的位置,一般是在 App.js 中调用。
|
63
|
+
|
64
|
+
```ts
|
65
|
+
import logger from '@wutiange/log-listener-plugin';
|
66
|
+
// 启动日志记录
|
67
|
+
logger.config({isAuto: true});
|
68
|
+
```
|
69
|
+
|
70
|
+
### 2.2 基于手动设置的方式使用
|
71
|
+
|
72
|
+
```ts
|
73
|
+
import logger from '@wutiange/log-listener-plugin';
|
74
|
+
// 填写日志服务器的地址,如果你使用自我发现功能,那么这一步可以省略
|
75
|
+
logger.config({isAuto: true, testUrl: 'http://127.0.0.1'});
|
76
|
+
```
|
77
|
+
|
78
|
+
### 2.3 设置基本数据
|
79
|
+
|
80
|
+
设置基础数据,一般数据从 react-native-device-info 中获取,如果你没有特殊的可以不要调用,内部会根据你安装的 react-native-device-info 自动获取基础数据。这些基础数据的目的是为了过滤数据,不是必须的。
|
81
|
+
|
82
|
+
```ts
|
83
|
+
logger.config({
|
84
|
+
baseData: {
|
85
|
+
Brand: DeviceInfo.getBrand(),
|
86
|
+
Model: DeviceInfo.getModel(),
|
87
|
+
AppVersion: DeviceInfo.getVersion(),
|
88
|
+
Carrier: DeviceInfo.getCarrierSync(),
|
89
|
+
Manufacturer: DeviceInfo.getManufacturerSync(),
|
90
|
+
SystemName: DeviceInfo.getSystemName(),
|
91
|
+
}
|
92
|
+
});
|
93
|
+
```
|
94
|
+
|
95
|
+
### 2.4 单独记录和停止所有记录
|
96
|
+
|
97
|
+
尽量不要使用以下 API ,这些 API 也没必要,这些数据都只会保存到你打开的日志系统中,所以都是能收集啥就都收集啥,目的是方便排查问题。
|
98
|
+
|
99
|
+
```ts
|
100
|
+
// 只抓取日志
|
101
|
+
logger.startRecordLog();
|
102
|
+
// 只抓取网络日志
|
103
|
+
logger.startRecordNetwork();
|
104
|
+
|
105
|
+
// 停止日志记录,会同时停止日志和网络
|
106
|
+
logger.unAuto();
|
107
|
+
```
|
108
|
+
|
109
|
+
### 2.5 其他使用说明
|
110
|
+
|
111
|
+
如果你希望杀死手机后下次进来仍然能记住之前保存的 IP 地址,那么你可以考虑安装:
|
112
|
+
|
113
|
+
```bash
|
114
|
+
yarn add @react-native-async-storage/async-storage
|
115
|
+
```
|
116
|
+
|
117
|
+
如果你本地有安装其他的 storage ,那么你可以手动设置:
|
118
|
+
|
119
|
+
```ts
|
120
|
+
logger.config({
|
121
|
+
storage: // 你的 storage ;或者你自己写的,只要遵循 getItem 和 setItem 接口规范即可
|
122
|
+
})
|
123
|
+
```
|
124
|
+
|
125
|
+
现在把若干配置相关的都放到了 config 中,以此来简化配置,配置的每一项都是可选的:
|
126
|
+
|
127
|
+
```ts
|
128
|
+
type Options = {
|
129
|
+
/**
|
130
|
+
* storage 用于存储已设置的日志系统的 url
|
131
|
+
* @default @react-native-async-storage/async-storage
|
132
|
+
*/
|
133
|
+
storage?: Storage
|
134
|
+
/**
|
135
|
+
* 设置上传日志的超时时间,单位为毫秒
|
136
|
+
* @default 3000
|
137
|
+
*/
|
138
|
+
timeout?: number
|
139
|
+
/**
|
140
|
+
* 日志系统的url
|
141
|
+
*/
|
142
|
+
testUrl?: string
|
143
|
+
/**
|
144
|
+
* 是否自动开启日志记录
|
145
|
+
* @default false
|
146
|
+
*/
|
147
|
+
isAuto?: boolean
|
148
|
+
/**
|
149
|
+
* 设置日志系统的基础数据,这些数据会自动添加到每条日志中
|
150
|
+
*/
|
151
|
+
baseData?: Record<string, any>
|
152
|
+
}
|
153
|
+
```
|
154
|
+
|
155
|
+
这是 config 每一项的说明。
|
156
|
+
|
157
|
+
## 3. 其他重要说明
|
158
|
+
|
159
|
+
1. 如果你使用的自我发现模式,那么要保证你的手机和 log-record 客户端在同一个局域网下。
|
160
|
+
1. 在配置 baseUrl 的时候,必须填写的是 [log-record](https://github.com/wutiange/log-record) 的地址,也就是你在什么电脑打开的 log-record 客户端,那么这里添加的就是对应电脑的 ip 地址。集成这个插件的 app 端要保证跟 log-record 客户端在同一个局域网下。
|
161
|
+
1. 如果你不知道日志系统的 IP ,可以在日志系统的 `设置 > 链接说明(需要版本大于1.0.9)` 中找到,如下图所示:
|
162
|
+
|
163
|
+
![0cf34d6cd25ee1f725b57dd2d076c336.png](docs/images/0cf34d6cd25ee1f725b57dd2d076c336.png)
|
@@ -29,18 +29,18 @@ describe('Server', () => {
|
|
29
29
|
describe('Constructor and URL Management', () => {
|
30
30
|
it('should initialize with default values', () => {
|
31
31
|
server = new Server_1.default();
|
32
|
-
expect(server.
|
32
|
+
expect(server.getBaseUrlArr()).toEqual(new Set([]));
|
33
33
|
});
|
34
34
|
it('should initialize with custom URL', () => {
|
35
35
|
server = new Server_1.default('localhost:8080');
|
36
|
-
expect(server.
|
36
|
+
expect(server.getBaseUrlArr()).toEqual(new Set(['http://localhost:8080']));
|
37
37
|
});
|
38
38
|
it('should handle URLs with and without http prefix', () => {
|
39
39
|
server = new Server_1.default();
|
40
40
|
server.updateUrl('localhost:8080');
|
41
|
-
expect(server.
|
41
|
+
expect(server.getBaseUrlArr()).toEqual(new Set(['http://localhost:8080']));
|
42
42
|
server.updateUrl('http://localhost:8080');
|
43
|
-
expect(server.
|
43
|
+
expect(server.getBaseUrlArr()).toEqual(new Set(['http://localhost:8080']));
|
44
44
|
});
|
45
45
|
});
|
46
46
|
describe('ZeroConf Handling', () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Server.test.js","sourceRoot":"","sources":["../../../src/__tests__/Server.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAA+B;AAC/B,oCAAiC;AAGjC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;IACzB,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,uCACK,MAAM,KACT,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,IAChB;AACJ,CAAC,CAAC,CAAC;AAIH,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAGvE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEzB,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,MAAc,CAAC;IAEnB,UAAU,CAAC,GAAG,EAAE;QAEd,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,MAAM,CAAC,KAAmB,CAAC,SAAS,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAC9C,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;YACtB,MAAM,CAAC,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"Server.test.js","sourceRoot":"","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,gBAAgB,CAAC,gBAAgB,CAAC;aAChD,CAAC,CACH,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
import '../../console';
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
require("../../console");
|
7
|
+
const index_1 = __importDefault(require("../../index"));
|
8
|
+
describe("重写日志", () => {
|
9
|
+
it("log 没有提前设置 url", () => {
|
10
|
+
console.log("log 是否正常打印");
|
11
|
+
expect(1).toBe(1);
|
12
|
+
});
|
13
|
+
it("log 提前设置了 url", () => {
|
14
|
+
index_1.default.setBaseUrl("http://192.168.118.103");
|
15
|
+
console.log("log 是否正常打印");
|
16
|
+
expect(1).toBe(1);
|
17
|
+
});
|
18
|
+
it('warn', () => {
|
19
|
+
index_1.default.setBaseUrl("http://192.168.118.103");
|
20
|
+
console.warn("warn 是否正常打印");
|
21
|
+
expect(1).toBe(1);
|
22
|
+
});
|
23
|
+
it('error', () => {
|
24
|
+
index_1.default.setBaseUrl("http://192.168.118.103");
|
25
|
+
console.error("error 是否正常打印");
|
26
|
+
expect(1).toBe(1);
|
27
|
+
});
|
28
|
+
});
|
29
|
+
//# sourceMappingURL=console.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"console.test.js","sourceRoot":"","sources":["../../../src/__tests__/console.test.ts"],"names":[],"mappings":";;;;;AAAA,yBAAsB;AACtB,wDAAgC;AAChC,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACzB,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;QACvB,eAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAC3C,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACzB,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACd,eAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAC3C,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC3B,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACf,eAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAC3C,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAC7B,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -8,7 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const logger_1 = __importDefault(require("../logger"));
|
12
16
|
const utils_1 = require("../utils");
|
13
17
|
describe('createClassWithErrorHandling', () => {
|
14
18
|
class TestClass {
|
@@ -31,7 +35,7 @@ describe('createClassWithErrorHandling', () => {
|
|
31
35
|
}
|
32
36
|
let consoleErrorSpy;
|
33
37
|
beforeEach(() => {
|
34
|
-
consoleErrorSpy = jest.spyOn(
|
38
|
+
consoleErrorSpy = jest.spyOn(logger_1.default, 'error').mockImplementation(() => { });
|
35
39
|
});
|
36
40
|
afterEach(() => {
|
37
41
|
consoleErrorSpy.mockRestore();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../src/__tests__/utils.test.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../src/__tests__/utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAA+B;AAC/B,oCAAiE;AAEjE,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,MAAM,SAAS;QACb,YAAY;YACV,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,WAAW;YACT,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QAEK,WAAW;;gBACf,OAAO,OAAO,CAAC;YACjB,CAAC;SAAA;QAEK,gBAAgB;;gBACpB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACtC,CAAC;SAAA;KACF;IAED,IAAI,eAAiC,CAAC;IAEtC,UAAU,CAAC,GAAG,EAAE;QACd,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAM,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACpD,MAAM,aAAa,GAAG,IAAA,oCAA4B,EAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,CAAC,Y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M,CAAC,IAAA,eAAO,EAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,IAAA,eAAO,EAAC,mCAAmC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,CAAC,IAAA,eAAO,EAAC,8BAA8B,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/common.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare const URLS_KEY = "log-listener-plugin-urls$$
|
1
|
+
export declare const URLS_KEY = "log-listener-plugin-urls$$SetKey";
|
2
2
|
export declare const DEFAULT_TIMEOUT = 3000;
|
3
3
|
export declare const LOG_KEY = "[@wutiange/log-listener-plugin \u65E5\u5FD7]";
|
4
4
|
export declare enum Level {
|
package/dist/src/common.js
CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.getErrMsg = exports.getDefaultStorage = exports.getBaseData = exports.Tag = exports.Level = exports.LOG_KEY = exports.DEFAULT_TIMEOUT = exports.URLS_KEY = void 0;
|
7
7
|
const logger_1 = __importDefault(require("./logger"));
|
8
|
-
exports.URLS_KEY = 'log-listener-plugin-urls$$
|
8
|
+
exports.URLS_KEY = 'log-listener-plugin-urls$$SetKey';
|
9
9
|
exports.DEFAULT_TIMEOUT = 3000;
|
10
10
|
exports.LOG_KEY = '[@wutiange/log-listener-plugin 日志]';
|
11
11
|
var Level;
|
package/dist/src/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8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,EAC9C,UAAU,EAAE,UAAU,CAAC,aAAa,EAAE,IACnC,oBAAoB,EAAE,EACzB;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,oBAAoB,EAAE,CAAA;IAC/B,CAAC;AACH,CAAC,CAAA;AAhBY,QAAA,WAAW,eAgBvB;AAEM,MAAM,iBAAiB,GAAG,GAAY,EAAE;;IAC7C,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,2CAA2C,CAAC,0CAAE,OAAO,CAAC;QACnF,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAA;AAPY,QAAA,iBAAiB,qBAO7B;AAGM,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE;;IACtC,OAAO;QACL,OAAO,EAAE;YACP,GACE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,KACpB,kHAAkH;SACnH;QACD,GAAG,EAAE,GAAG,CAAC,yBAAyB;QAClC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;KACvB,CAAA;AACH,CAAC,CAAA;AAXY,QAAA,SAAS,aAWrB"}
|
package/dist/src/logPlugin.js
CHANGED
@@ -33,12 +33,12 @@ class LogPlugin {
|
|
33
33
|
const urlsStr = yield this.storage.getItem(common_1.URLS_KEY);
|
34
34
|
if (urlsStr) {
|
35
35
|
const urls = JSON.parse(urlsStr);
|
36
|
-
this.server.
|
36
|
+
this.server.setBaseUrlArr(new Set(urls));
|
37
37
|
}
|
38
38
|
}
|
39
|
-
this.server.addUrlsListener((
|
39
|
+
this.server.addUrlsListener((urlArr) => {
|
40
40
|
if (this.storage) {
|
41
|
-
this.storage.setItem(common_1.URLS_KEY, JSON.stringify(
|
41
|
+
this.storage.setItem(common_1.URLS_KEY, JSON.stringify(urlArr));
|
42
42
|
}
|
43
43
|
HTTPInterceptor_1.httpInterceptor.setIgnoredUrls(this.handleIgnoredUrls());
|
44
44
|
});
|
@@ -87,13 +87,12 @@ class LogPlugin {
|
|
87
87
|
};
|
88
88
|
this.handleIgnoredUrls = () => {
|
89
89
|
var _a, _b;
|
90
|
-
const urls = (_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.
|
91
|
-
|
92
|
-
if (urls === null || urls === void 0 ? void 0 : urls.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}, []);
|
90
|
+
const urls = (_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.getBaseUrlArr) === null || _b === void 0 ? void 0 : _b.call(_a);
|
91
|
+
const ignoredUrls = [];
|
92
|
+
if (urls === null || urls === void 0 ? void 0 : urls.size) {
|
93
|
+
urls.forEach((url) => {
|
94
|
+
ignoredUrls.push(`${url}/log`, `${url}/network`, `${url}/join`);
|
95
|
+
});
|
97
96
|
}
|
98
97
|
return ignoredUrls;
|
99
98
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logPlugin.js","sourceRoot":"","sources":["../../src/logPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,mCAAuD;AACvD,uDAAoD;AACpD,qCAA6F;AAC7F,sDAA8B;AA4B9B,MAAM,SAAS;IAMb;QALQ,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAkB,IAAI,CAAC;QAC9B,WAAM,GAAG,KAAK,CAAA;QACd,YAAO,GAAmB,IAAA,0BAAiB,GAAE,CAAC;QAM9C,SAAI,GAAG,GAAS,EAAE;YACxB,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,gBAAM,CAAC,IAAI,CAAC,gBAAO,EAAE,kEAAkE,CAAC,CAAA;YAC1F,CAAC;iBAAM,CAAC;gBACN,MAAM,OAAO,GAAG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C,GAAG,IAAW,EAAE,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,cAAK,CAAC,GAAG,EAAE,YAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC,CAAA;QAED,SAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,cAAK,CAAC,IAAI,EAAE,YAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAA;QAED,UAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;YACzB,IAAI,CAAC,IAAI,CAAC,cAAK,CAAC,KAAK,EAAE,YAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAA;QAjLC,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;CAkLF;AACD,MAAM,aAAa,GAAG,IAAA,oCAA4B,EAAC,SAAS,CAAC,CAAA;AAEpD,sCAAa;AADtB,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;AAEtC,kBAAe,SAAS,CAAC"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
declare class Server {
|
2
|
+
private baseUrlArr;
|
3
|
+
private urlsObj;
|
4
|
+
private timeout;
|
5
|
+
private baseData;
|
6
|
+
private urlsListener;
|
7
|
+
private innerBaseData;
|
8
|
+
constructor(url?: string | Set<string>, timeout?: number);
|
9
|
+
addUrlsListener: (onNewUrlCallback: (urls: Set<string>) => void) => void;
|
10
|
+
private requestJoin;
|
11
|
+
private handleZeroConf;
|
12
|
+
updateTimeout(timeout?: number): void;
|
13
|
+
private send;
|
14
|
+
updateUrl(url?: string): void;
|
15
|
+
setBaseUrlArr(urlArr?: Set<string>): void;
|
16
|
+
getBaseUrlArr(): Set<string>;
|
17
|
+
updateBaseData(data?: Record<string, any>): void;
|
18
|
+
log: (data: Record<string, any>) => Promise<void>;
|
19
|
+
network: (data: Record<string, any>) => Promise<void>;
|
20
|
+
}
|
21
|
+
export default Server;
|