Skip to content

Commit 97dbd37

Browse files
committed
Properly clone maps and sets, fix #213
1 parent 91de366 commit 97dbd37

3 files changed

Lines changed: 32 additions & 21 deletions

File tree

docs/index.html

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<title>tslog - 📝 Extensible TypeScript Logger for Node.js and Browser: Dependency free, Fully customizable, Pretty errors, stack traces, and JSON output to attachable transports.</title>
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7-
<meta name="description" content="📝 Extensible TypeScript Logger for Node.js and Browser: Dependency free, Fully customizable, Pretty errors, stack traces, and JSON output to attachable transports.">
8-
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9-
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
10-
</head>
11-
<body>
12-
<div id="app"></div>
13-
<script>
14-
window.$docsify = {
15-
name: 'tslog',
16-
repo: 'https://github.com/fullstack-build/tslog'
17-
}
18-
</script>
19-
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
20-
</body>
21-
</html>
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>tslog - 📝 Extensible TypeScript Logger for Node.js and Browser: dependency free, fully customizable, pretty errors, stack traces, and JSON output to attachable transports.</title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7+
<meta name="description" content="📝 Extensible TypeScript Logger for Node.js and Browser: dependency free, fully customizable, pretty errors, stack traces, and JSON output to attachable transports.">
8+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9+
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
10+
</head>
11+
<body>
12+
<div id="app"></div>
13+
<script>
14+
window.$docsify = {
15+
name: 'tslog',
16+
repo: 'https://github.com/fullstack-build/tslog'
17+
}
18+
</script>
19+
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
20+
</body>
21+
</html>

examples/nodejs/index2.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ const performanceLogger = new Logger({
6363
});
6464

6565
performanceLogger.silly("log without code position information");
66+
67+
////////////////////////////
68+
const loggerMap = new Logger({ name: 'mapLogger'});
69+
70+
let map = new Map();
71+
map.set('foo', 'bar');
72+
loggerMap.debug('My Map: ', map) // prints in console "DEBUG myLogger My Map: {}"

src/BaseLogger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ export class BaseLogger<LogObj> {
204204
? source // dont copy Error
205205
: isBuffer(source)
206206
? source // dont copy Buffer
207+
: source instanceof Map ?
208+
new Map(source)
209+
: source instanceof Set ?
210+
new Set(source)
207211
: Array.isArray(source)
208212
? source.map((item) => this._recursiveCloneAndMaskValuesOfKeys(item, keys, seen))
209213
: source instanceof Date

0 commit comments

Comments
 (0)