Skip to content

Commit

Permalink
fix console plugin example
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuyz0112 committed Jul 25, 2022
1 parent ba4bcbe commit 16089fc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
34 changes: 20 additions & 14 deletions docs/recipes/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}),
],
});
```

Expand Down
34 changes: 20 additions & 14 deletions docs/recipes/console.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
// 使用默认的配置选项
Expand All @@ -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,
}),
],
});
```

Expand Down

0 comments on commit 16089fc

Please sign in to comment.