From c22eea56bd3762e210ebfb6c94cf995d0ce630f0 Mon Sep 17 00:00:00 2001 From: Navy Date: Tue, 14 Apr 2020 18:05:37 +0300 Subject: [PATCH] random bs --- middleware/logger/transports/FileExtension.js | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/middleware/logger/transports/FileExtension.js b/middleware/logger/transports/FileExtension.js index ef48f80..b4b0b51 100644 --- a/middleware/logger/transports/FileExtension.js +++ b/middleware/logger/transports/FileExtension.js @@ -1,10 +1,10 @@ +/* eslint-disable no-control-regex */ const { transports: { File }} = require('winston'); const debug = require('diagnostics')('winston:file'); const { MESSAGE } = require('triple-beam'); const moment = require('moment'); -const chalk = require('chalk'); -const regex = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g +const regex = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; class FileExtension extends File { @@ -17,28 +17,28 @@ class FileExtension extends File { // when thinking about 3.x? Should silent be handled in the base // TransportStream _write method? if (this.silent) { - callback(); - return true; + callback(); + return true; } // Output stream buffer is full and has asked us to wait for the drain event if (this._drain) { - this._stream.once('drain', () => { - this._drain = false; - this.log(info, callback); - }); - return; + this._stream.once('drain', () => { + this._drain = false; + this.log(info, callback); + }); + return; } if (this._rotate) { - this._stream.once('rotate', () => { - this._rotate = false; - this.log(info, callback); - }); - return; + this._stream.once('rotate', () => { + this._rotate = false; + this.log(info, callback); + }); + return; } // Grab the raw string and append the expected EOL. - const output = `${info[MESSAGE]}${this.eol}`.replace(regex, '') + const output = `${info[MESSAGE]}${this.eol}`.replace(regex, ''); const bytes = Buffer.byteLength(output); // After we have written to the PassThrough check to see if we need @@ -47,27 +47,27 @@ class FileExtension extends File { // Remark: This gets called too early and does not depict when data // has been actually flushed to disk. function logged() { - this._size += bytes; - this._pendingSize -= bytes; + this._size += bytes; + this._pendingSize -= bytes; - debug('logged %s %s', this._size, output); - this.emit('logged', info); + debug('logged %s %s', this._size, output); + this.emit('logged', info); - // Do not attempt to rotate files while opening - if (this._opening) { - return; - } + // Do not attempt to rotate files while opening + if (this._opening) { + return; + } - // Check to see if we need to end the stream and create a new one. - if (!this._needsNewFile()) { - return; - } + // Check to see if we need to end the stream and create a new one. + if (!this._needsNewFile()) { + return; + } - // End the current stream, ensure it flushes and create a new one. - // This could potentially be optimized to not run a stat call but its - // the safest way since we are supporting `maxFiles`. - this._rotate = true; - this._endStream(() => this._rotateFile()); + // End the current stream, ensure it flushes and create a new one. + // This could potentially be optimized to not run a stat call but its + // the safest way since we are supporting `maxFiles`. + this._rotate = true; + this._endStream(() => this._rotateFile()); } // Keep track of the pending bytes being written while files are opening @@ -77,18 +77,18 @@ class FileExtension extends File { if (this._opening && !this.rotatedWhileOpening && this._needsNewFile(this._size + this._pendingSize)) { - this.rotatedWhileOpening = true; + this.rotatedWhileOpening = true; } const written = this._stream.write(output, logged.bind(this)); if (!written) { - this._drain = true; - this._stream.once('drain', () => { - this._drain = false; - callback(); - }); + this._drain = true; + this._stream.once('drain', () => { + this._drain = false; + callback(); + }); } else { - callback(); // eslint-disable-line callback-return + callback(); // eslint-disable-line callback-return } debug('written', written, this._drain); @@ -96,7 +96,7 @@ class FileExtension extends File { this.finishIfEnding(); return written; - } + } get date() { return moment().format("MM-DD-YYYY hh:mm:ss");