+19
-11
@@ -59,4 +59,2 @@ 'use strict'; | ||
| const normalizeStack = stack => stack.replace(/\s+at\s+/g, '\n\t'); | ||
| const lineStack = stack => stack.replace(/[\n\r]\s*/g, '; '); | ||
@@ -73,6 +71,7 @@ | ||
| // Writable <class> writable stream class | ||
| // home <string> remove home paths from stack traces | ||
| constructor(options) { | ||
| super(); | ||
| const { path, workerId = 0, Writable = WritableFileStream } = options; | ||
| const { writeInterval, writeBuffer, keepDays } = options; | ||
| const { writeInterval, writeBuffer, keepDays, home } = options; | ||
| const { toFile, toStdout } = options; | ||
@@ -86,2 +85,3 @@ this.active = false; | ||
| this.keepDays = keepDays || 0; | ||
| this.home = home ? new RegExp(home, 'g') : null; | ||
| this.options = { flags: 'a', bufferSize: this.writeBuffer }; | ||
@@ -101,7 +101,7 @@ this.stream = null; | ||
| async open() { | ||
| if (this.active) return; | ||
| if (this.active) return this; | ||
| this.active = true; | ||
| if (!this.fsEnabled) { | ||
| process.nextTick(() => this.emit('open')); | ||
| return; | ||
| return this; | ||
| } | ||
@@ -136,10 +136,12 @@ const date = common.nowDate(); | ||
| async close() { | ||
| if (!this.active) return; | ||
| if (!this.active) return Promise.resolve(); | ||
| if (!this.fsEnabled) { | ||
| this.active = false; | ||
| this.emit('close'); | ||
| return; | ||
| return Promise.resolve(); | ||
| } | ||
| const { stream } = this; | ||
| if (!stream || stream.destroyed || stream.closed) return; | ||
| if (!stream || stream.destroyed || stream.closed) { | ||
| return Promise.resolve(); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
@@ -247,2 +249,8 @@ this.flush(err => { | ||
| normalizeStack(stack) { | ||
| let res = stack.replace(/\s+at\s+/g, '\n\t'); | ||
| if (this.home) res = res.replace(this.home, ''); | ||
| return res; | ||
| } | ||
| system(message) { | ||
@@ -253,3 +261,3 @@ this.write('system', message); | ||
| fatal(message) { | ||
| const msg = normalizeStack(message); | ||
| const msg = this.normalizeStack(message); | ||
| this.write('fatal', msg); | ||
@@ -259,3 +267,3 @@ } | ||
| error(message) { | ||
| const msg = normalizeStack(message); | ||
| const msg = this.normalizeStack(message); | ||
| this.write('error', msg); | ||
@@ -273,3 +281,3 @@ } | ||
| debug(message) { | ||
| const msg = normalizeStack(message); | ||
| const msg = this.normalizeStack(message); | ||
| this.write('debug', msg); | ||
@@ -276,0 +284,0 @@ } |
+7
-6
| { | ||
| "name": "metalog", | ||
| "version": "2.1.0", | ||
| "version": "2.2.0", | ||
| "author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -43,3 +43,2 @@ "description": "Logger for Metarhia", | ||
| "concolor": "^0.1.14", | ||
| "diff": "^4.0.2", | ||
| "metastreams": "^0.1.2" | ||
@@ -49,7 +48,9 @@ }, | ||
| "eslint": "^7.1.0", | ||
| "eslint-config-prettier": "^6.11.0", | ||
| "eslint-plugin-prettier": "^3.1.3", | ||
| "metatests": "^0.7.1", | ||
| "prettier": "^1.19.1" | ||
| "eslint-config-metarhia": "^7.0.0", | ||
| "eslint-config-prettier": "^6.9.0", | ||
| "eslint-plugin-import": "^2.20.0", | ||
| "eslint-plugin-prettier": "^3.1.1", | ||
| "prettier": "^1.19.1", | ||
| "metatests": "^0.7.1" | ||
| } | ||
| } |
+2
-1
@@ -23,2 +23,3 @@ # Meta Logger for Metarhia | ||
| This implementation of Web Locks API is [MIT licensed](./LICENSE). | ||
| Copyright (c) 2017-2020 Metarhia contributors. | ||
| Metalog is [MIT licensed](./LICENSE). |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
11015
3.4%3
-25%266
3.1%25
4.17%7
40%- Removed
- Removed