fix console plugin example

This commit is contained in:
Yanzhen Yu
2022-07-25 23:56:01 +08:00
parent ba4bcbea8d
commit 16089fc6b5
2 changed files with 40 additions and 28 deletions

View File

@@ -9,9 +9,11 @@ You can enable the logger using default option like this:
```js ```js
rrweb.record({ rrweb.record({
emit: emit(event) { emit: function emit(event) {
// you should use console.log in this way to avoid errors. // you should use console.log in this way to avoid errors.
const defaultLog = console.log["__rrweb_original__"] ? console.log["__rrweb_original__"] : console.log; const defaultLog = console.log['__rrweb_original__']
? console.log['__rrweb_original__']
: console.log;
defaultLog(event); defaultLog(event);
}, },
// to use default record option // to use default record option
@@ -26,22 +28,26 @@ You can also customize the behavior of logger like this:
```js ```js
rrweb.record({ rrweb.record({
emit: emit(event) { emit: function emit(event) {
// you should use console.log in this way to avoid errors. // you should use console.log in this way to avoid errors.
const defaultLog = console.log["__rrweb_original__"] ? console.log["__rrweb_original__"] : console.log; const defaultLog = console.log['__rrweb_original__']
? console.log['__rrweb_original__']
: console.log;
defaultLog(event); defaultLog(event);
}, },
// customized options // customized options
plugins: [rrweb.getRecordConsolePlugin({ plugins: [
level: ["info", "log", "warn", "error"], rrweb.getRecordConsolePlugin({
lengthThreshold: 10000, level: ['info', 'log', 'warn', 'error'],
stringifyOptions: { lengthThreshold: 10000,
stringLengthLimit: 1000, stringifyOptions: {
numOfKeysLimit: 100, stringLengthLimit: 1000,
depthOfLimit: 1 numOfKeysLimit: 100,
}, depthOfLimit: 1,
logger: window.console, },
})], logger: window.console,
}),
],
}); });
``` ```

View File

@@ -8,9 +8,11 @@
```js ```js
rrweb.record({ rrweb.record({
emit: emit(event) { emit: function emit(event) {
// 如果要使用console来输出信息请使用如下的写法 // 如果要使用console来输出信息请使用如下的写法
const defaultLog = console.log["__rrweb_original__"] ? console.log["__rrweb_original__"] : console.log; const defaultLog = console.log['__rrweb_original__']
? console.log['__rrweb_original__']
: console.log;
defaultLog(event); defaultLog(event);
}, },
// 使用默认的配置选项 // 使用默认的配置选项
@@ -25,22 +27,26 @@ rrweb.record({
```js ```js
rrweb.record({ rrweb.record({
emit: emit(event) { emit: function emit(event) {
// 如果要使用console来输出信息请使用如下的写法 // 如果要使用console来输出信息请使用如下的写法
const defaultLog = console.log["__rrweb_original__"] ? console.log["__rrweb_original__"] : console.log; const defaultLog = console.log['__rrweb_original__']
? console.log['__rrweb_original__']
: console.log;
defaultLog(event); defaultLog(event);
}, },
// 定制的选项 // 定制的选项
plugins: [rrweb.getRecordConsolePlugin({ plugins: [
level: ["info", "log", "warn", "error"], rrweb.getRecordConsolePlugin({
lengthThreshold: 10000, level: ['info', 'log', 'warn', 'error'],
stringifyOptions: { lengthThreshold: 10000,
stringLengthLimit: 1000, stringifyOptions: {
numOfKeysLimit: 100, stringLengthLimit: 1000,
depthOfLimit: 1 numOfKeysLimit: 100,
}, depthOfLimit: 1,
logger: window.console, },
})], logger: window.console,
}),
],
}); });
``` ```