Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@voliware/logger

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voliware/logger - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

10

package.json
{
"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"
}
}

25

src/mongoDbLogger.js

@@ -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);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc