@voliware/logger
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "@voliware/logger", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A tiny Javascript logger with levels and several options. Supports Node, MongoDB, and all modern Browsers", | ||
@@ -29,8 +29,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@voliware/node-mongo": "^1.1.2", | ||
"mocha": "^6.2.1" | ||
}, | ||
"dependencies": { | ||
"@voliware/node-build": "^1.0.3" | ||
"@voliware/node-build": "^1.7.3", | ||
"mocha": "^6.2.1", | ||
"mongodb": "^4.1.0" | ||
} | ||
} |
@@ -33,19 +33,10 @@ const Logger = require('./logger'); | ||
this.collection = collection; | ||
this.log_count = this.collection.getDocumentCount(); | ||
this.log_count = this.collection.countDocuments(); | ||
} | ||
/** | ||
* Check the number of logs and if higher than count, remove the first log. | ||
*/ | ||
checkLogCount(){ | ||
if(this.log_count >= this.maxlogs){ | ||
this.collection.deleteDocument(); | ||
} | ||
} | ||
/** | ||
* Clear the collection | ||
*/ | ||
clear(){ | ||
this.collection.wipe(); | ||
this.collection.deleteMany({}); | ||
} | ||
@@ -59,3 +50,3 @@ | ||
_verbose(message){ | ||
return this.collection.insertDocument(message); | ||
return this.collection.insertOne(message); | ||
} | ||
@@ -69,3 +60,3 @@ | ||
_debug(message){ | ||
return this.collection.insertDocument(message); | ||
return this.collection.insertOne(message); | ||
} | ||
@@ -79,3 +70,3 @@ | ||
_info(message){ | ||
return this.collection.insertDocument(message); | ||
return this.collection.insertOne(message); | ||
} | ||
@@ -89,3 +80,3 @@ | ||
_warning(message){ | ||
return this.collection.insertDocument(message); | ||
return this.collection.insertOne(message); | ||
} | ||
@@ -99,3 +90,3 @@ | ||
_error(message){ | ||
return this.collection.insertDocument(message); | ||
return this.collection.insertOne(message); | ||
} | ||
@@ -108,3 +99,3 @@ | ||
deleteFirstDocument(){ | ||
return this.collection.deleteDocument(); | ||
return this.collection.deleteOne({}); | ||
} | ||
@@ -111,0 +102,0 @@ |
const Assert = require('assert'); | ||
const Fs = require('fs'); | ||
const Logger = require('../index'); | ||
const MongoClient = require('mongodb').MongoClient; | ||
const Path = require('path'); | ||
const Logger = require('../index'); | ||
const {Database} = require('@voliware/node-mongo'); | ||
@@ -17,8 +17,13 @@ describe('Logger', function() { | ||
// Mongo DB Logger | ||
this.db = new Database({ | ||
name: "logger-testing", | ||
log_level: false | ||
const url = "mongodb://localhost:27017/logger-testing?retryWrites=true&w=majority" | ||
this.mongoclient = new MongoClient(url, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true | ||
}); | ||
await this.db.initialize(); | ||
this.collection = await this.db.getCollection('logs') | ||
await this.mongoclient.connect(); | ||
this.db = this.mongoclient.db("logger-testing"); | ||
await this.db.createCollection("logs").catch(error => { | ||
// Already exists | ||
}) | ||
this.collection = this.db.collection('logs') | ||
this.mongologger = new Logger.MongoDbLogger("App", { | ||
@@ -31,3 +36,3 @@ collection: this.collection, | ||
after(function() { | ||
this.db.client.close(); | ||
this.mongoclient.close(); | ||
}); | ||
@@ -133,3 +138,3 @@ | ||
await this.mongologger.info("Test 1"); | ||
const data = await this.collection.getDocument(); | ||
const data = await this.collection.findOne(); | ||
Assert.strictEqual(data.context, ''); | ||
@@ -145,3 +150,3 @@ Assert.strictEqual(data.level, '[INF] '); | ||
await this.mongologger.deleteFirstDocument(); | ||
const data = await this.collection.getDocument(); | ||
const data = await this.collection.findOne(); | ||
Assert.strictEqual(data.context, ''); | ||
@@ -156,5 +161,5 @@ Assert.strictEqual(data.level, '[INF] '); | ||
await this.mongologger.clear(); | ||
const data = await this.collection.getDocument(); | ||
Assert.strictEqual(data, null); | ||
const data = await this.collection.findOne(); | ||
Assert.strictEqual(data, undefined); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
38892
3
926
- Removed@voliware/node-build@^1.0.3
- Removed@node-minify/clean-css@5.3.0(transitive)
- Removed@node-minify/core@5.3.0(transitive)
- Removed@node-minify/html-minifier@5.3.0(transitive)
- Removed@node-minify/uglify-es@5.3.0(transitive)
- Removed@node-minify/utils@5.3.0(transitive)
- Removed@voliware/logger@1.6.2(transitive)
- Removed@voliware/node-build@1.7.3(transitive)
- Removed@voliware/node-data-transform@1.2.1(transitive)
- Removed@voliware/node-minify-transform@0.1.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcamel-case@3.0.0(transitive)
- Removedclean-css@4.2.1(transitive)
- Removedcommander@2.13.02.20.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedduplexer@0.1.2(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.1.67.2.3(transitive)
- Removedgzip-size@5.1.1(transitive)
- Removedhe@1.2.0(transitive)
- Removedhtml-minifier@4.0.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlower-case@1.1.4(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.5.1(transitive)
- Removedno-case@2.3.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedparam-case@2.1.1(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpify@4.0.1(transitive)
- Removedrelateurl@0.2.7(transitive)
- Removedsource-map@0.6.1(transitive)
- Removeduglify-es@3.3.9(transitive)
- Removeduglify-js@3.19.3(transitive)
- Removedupper-case@1.1.3(transitive)
- Removedwrappy@1.0.2(transitive)