@@ -19,37 +19,37 @@ const helpers = require('./helpers');
19
19
/**
20
20
* Constructor for the MongoDB transport object.
21
21
* @constructor
22
- * @param {Object } options
23
- * @param {string=info } options.level Level of messages that this transport
22
+ * @param {Object } options Options
23
+ * @param {string } [ options.level=info] Level of messages that this transport
24
24
* should log.
25
- * @param {boolean=false } options.silent Boolean flag indicating whether to
25
+ * @param {boolean } [ options.silent=false] Boolean flag indicating whether to
26
26
* suppress output.
27
27
* @param {string|Object } options.db MongoDB connection uri or preconnected db
28
28
* object.
29
29
* @param {string } options.dbName The database name to connect to,
30
30
* defaults to DB name based on connection URI if not provided
31
31
* @param {Object } options.options MongoDB connection parameters
32
32
* (optional, defaults to `{poolSize: 2, autoReconnect: true, useNewUrlParser: true}`).
33
- * @param {string=logs } options.collection The name of the collection you want
33
+ * @param {string } [ options.collection=log] The name of the collection you want
34
34
* to store log messages in.
35
- * @param {boolean=false } options.storeHost Boolean indicating if you want to
35
+ * @param {boolean } [ options.storeHost=false] Boolean indicating if you want to
36
36
* store machine hostname in logs entry, if set to true it populates MongoDB
37
37
* entry with 'hostname' field, which stores os.hostname() value.
38
38
* @param {string } options.label Label stored with entry object if defined.
39
39
* @param {string } options.name Transport instance identifier. Useful if you
40
40
* need to create multiple MongoDB transports.
41
- * @param {boolean=false } options.capped In case this property is true,
41
+ * @param {boolean } [ options.capped=false] In case this property is true,
42
42
* winston-mongodb will try to create new log collection as capped.
43
- * @param {number=10000000 } options.cappedSize Size of logs capped collection
43
+ * @param {number } [ options.cappedSize=10000000] Size of logs capped collection
44
44
* in bytes.
45
45
* @param {number } options.cappedMax Size of logs capped collection in number
46
46
* of documents.
47
- * @param {boolean=false } options.tryReconnect Will try to reconnect to the
47
+ * @param {boolean } [ options.tryReconnect=false] Will try to reconnect to the
48
48
* database in case of fail during initialization. Works only if `db` is
49
49
* a string.
50
- * @param {boolean=false } options.decolorize Will remove color attributes from
50
+ * @param {boolean } [ options.decolorize=false] Will remove color attributes from
51
51
* the log entry message.
52
- * @param {boolean=false } options.leaveConnectionOpen Will leave MongoClient connected
52
+ * @param {boolean } [ options.leaveConnectionOpen=false] Will leave MongoClient connected
53
53
* after transport shut down.
54
54
* @param {number } options.expireAfterSeconds Seconds before the entry is removed.
55
55
* Do not use if capped is set.
@@ -189,7 +189,7 @@ MongoDB.prototype.close = function () {
189
189
if ( ! this . mongoClient || this . leaveConnectionOpen ) {
190
190
return ;
191
191
}
192
- this . mongoClient . close ( ) . then ( ( ) => this . mongoClient = null ) . catch ( err => {
192
+ this . mongoClient . close ( ) . then ( ( ) => { this . mongoClient = null ; } ) . catch ( err => {
193
193
console . error ( 'Winston MongoDB transport encountered on error during '
194
194
+ 'closing.' , err ) ;
195
195
} ) ;
@@ -200,6 +200,7 @@ MongoDB.prototype.close = function () {
200
200
* Core logging method exposed to Winston. Metadata is optional.
201
201
* @param {Object } info Logging metadata
202
202
* @param {Function } cb Continuation to respond to when complete.
203
+ * @returns {boolean } Result boolean
203
204
*/
204
205
MongoDB . prototype . log = function ( info , cb ) {
205
206
if ( ! this . logDb ) {
@@ -213,8 +214,10 @@ MongoDB.prototype.log = function (info, cb) {
213
214
// If database logs, better not to call database itself in the same call.
214
215
process . nextTick ( ( ) => {
215
216
if ( this . silent ) {
217
+ // eslint-disable-next-line callback-return
216
218
cb ( null , true ) ;
217
219
}
220
+ // eslint-disable-next-line no-control-regex
218
221
const decolorizeRegex = new RegExp ( / \u001b \[ [ 0 - 9 ] { 1 , 2 } m / g) ;
219
222
const entry = { timestamp : new Date ( ) , level : ( this . decolorize ) ? info . level . replace ( decolorizeRegex , '' ) : info . level } ;
220
223
const msg = util . format ( info . message , ...( info . splat || [ ] ) ) ;
@@ -250,7 +253,6 @@ MongoDB.prototype.log = function (info, cb) {
250
253
* Query the transport. Options object is optional.
251
254
* @param {Object= } optOptions Loggly-like query options for this instance.
252
255
* @param {Function } cb Continuation to respond to when complete.
253
- * @returns {* }
254
256
*/
255
257
MongoDB . prototype . query = function ( optOptions , cb ) {
256
258
if ( ! this . logDb ) {
@@ -285,7 +287,7 @@ MongoDB.prototype.query = function (optOptions, cb) {
285
287
* This will only work with a capped collection.
286
288
* @param {Object } options Stream options for this instance.
287
289
* @param {Stream } stream Pass in a pre-existing stream.
288
- * @returns {Stream }
290
+ * @returns {Stream } Log stream for the transport
289
291
*/
290
292
MongoDB . prototype . stream = function ( options , stream ) {
291
293
options = options || { } ;
@@ -343,7 +345,7 @@ MongoDB.prototype.stream = function (options, stream) {
343
345
* Returns a log stream for this transport. Options object is optional.
344
346
* @param {Object } options Stream options for this instance.
345
347
* @param {Stream } stream Pass in a pre-existing stream.
346
- * @returns {Stream }
348
+ * @returns {Stream } Log stream for the transport
347
349
*/
348
350
MongoDB . prototype . streamPoll = function ( options , stream ) {
349
351
options = options || { } ;
@@ -398,6 +400,7 @@ MongoDB.prototype.streamPoll = function (options, stream) {
398
400
if ( stream . destroyed ) {
399
401
return ;
400
402
}
403
+ // eslint-disable-next-line callback-return
401
404
next ( ) ;
402
405
stream . emit ( 'error' , err ) ;
403
406
} ) ;
0 commit comments