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
rrweb.record({
emit: emit(event) {
emit: function emit(event) {
// 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);
},
// to use default record option
@@ -26,22 +28,26 @@ You can also customize the behavior of logger like this:
```js
rrweb.record({
emit: emit(event) {
emit: function emit(event) {
// 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);
},
// customized options
plugins: [rrweb.getRecordConsolePlugin({
level: ["info", "log", "warn", "error"],
lengthThreshold: 10000,
stringifyOptions: {
stringLengthLimit: 1000,
numOfKeysLimit: 100,
depthOfLimit: 1
},
logger: window.console,
})],
plugins: [
rrweb.getRecordConsolePlugin({
level: ['info', 'log', 'warn', 'error'],
lengthThreshold: 10000,
stringifyOptions: {
stringLengthLimit: 1000,
numOfKeysLimit: 100,
depthOfLimit: 1,
},
logger: window.console,
}),
],
});
```

View File

@@ -8,9 +8,11 @@
```js
rrweb.record({
emit: emit(event) {
emit: function emit(event) {
// 如果要使用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);
},
// 使用默认的配置选项
@@ -25,22 +27,26 @@ rrweb.record({
```js
rrweb.record({
emit: emit(event) {
emit: function emit(event) {
// 如果要使用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);
},
// 定制的选项
plugins: [rrweb.getRecordConsolePlugin({
level: ["info", "log", "warn", "error"],
lengthThreshold: 10000,
stringifyOptions: {
stringLengthLimit: 1000,
numOfKeysLimit: 100,
depthOfLimit: 1
},
logger: window.console,
})],
plugins: [
rrweb.getRecordConsolePlugin({
level: ['info', 'log', 'warn', 'error'],
lengthThreshold: 10000,
stringifyOptions: {
stringLengthLimit: 1000,
numOfKeysLimit: 100,
depthOfLimit: 1,
},
logger: window.console,
}),
],
});
```