@wutiange/log-listener-plugin 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +48 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,6 +5,53 @@
5
5
  [![npm downloads](https://img.shields.io/npm/dm/@wutiange/log-listener-plugin)](https://www.npmjs.com/package/@wutiange/log-listener-plugin)
6
6
  [![License](https://img.shields.io/npm/l/@wutiange/log-listener-plugin)](./LICENSE)
7
7
 
8
+ 中文 | [English](./docs/README_EN.md)
9
+
8
10
  要想正常使用 [log-record](https://github.com/wutiange/log-record) 客户端来收集日志,方便排查问题,那么就需要把这个插件安装到项目中。
9
11
 
10
- To properly use the [log-record](https://github.com/wutiange/log-record) client for collecting logs and facilitating troubleshooting, you need to install this plugin in your project.
12
+ ## 安装
13
+
14
+ 使用 npm 安装
15
+ ```bash
16
+ npm install @wutiange/log-listener-plugin
17
+ ```
18
+
19
+ 使用 yarn 安装
20
+ ```bash
21
+ yarn add @wutiange/log-listener-plugin
22
+ ```
23
+
24
+ ## 使用
25
+ 在项目的入口文件中引入,一般为 `index.ts` 文件。
26
+ ```ts
27
+ import logger from '@wutiange/log-listener-plugin';
28
+ // 填写日志服务器的地址
29
+ logger.setBaseUrl('http://127.0.0.1');
30
+ // 设置基础数据,一般数据从 react-native-device-info 中获取,这里你按自己的情况来上报即可,当然你也可以不设置
31
+ logger.setBaseData({
32
+ version: displayVersion,
33
+ brand: DeviceInfo.getBrand(),
34
+ model: DeviceInfo.getModel(),
35
+ appVersion: DeviceInfo.getVersion(),
36
+ carrier: DeviceInfo.getCarrierSync(),
37
+ manufacturer: DeviceInfo.getManufacturerSync(),
38
+ systemName: DeviceInfo.getSystemName(),
39
+ deviceUniqueId: DeviceInfo.getUniqueId(),
40
+ });
41
+
42
+ // 启动日志记录
43
+ logger.auto();
44
+
45
+ // 停止日志记录
46
+ logger.unAuto();
47
+ ```
48
+ 上面的是最简单的方式,如果你想只抓取日志或网络日志,那么可以采用下面的方式:
49
+ ```ts
50
+ // 只抓取日志
51
+ logger.startRecordLog();
52
+ // 只抓取网络日志
53
+ logger.startRecordNetwork();
54
+ ```
55
+
56
+ ## 其他重要说明
57
+ 在配置 baseUrl 的时候,必须填写的是 [log-record](https://github.com/wutiange/log-record) 的地址,也就是你在什么电脑打开的 log-record 客户端,那么这里添加的就是对应电脑的 ip 地址。集成这个插件的 app 端要保证跟 log-record 客户端在同一个局域网下。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wutiange/log-listener-plugin",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "log-record 客户端对应的的插件\r\nLog-record client corresponding plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",