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

@coya/logs

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coya/logs - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

54

logs.js

@@ -41,15 +41,12 @@ /* config {

if(config.outputCollection) {
this.error = db.bind(this, 'error');
this.warning = db.bind(this, 'warning');
this.notice = (msg) => { log.call(this, 'blue', msg); db.call(this, 'notice', msg); }; // write into logs and database
this.info = db.bind(this, 'info');
this.debug = db.bind(this, 'debug');
this.error = writeIntoDabase.bind(this, 'error');
this.warning = writeIntoDabase.bind(this, 'warning');
this.notice = (msg) => { log.call(this, 'blue', msg); writeIntoDabase.call(this, 'notice', msg); }; // write into logs and database
this.info = writeIntoDabase.bind(this, 'info');
this.debug = writeIntoDabase.bind(this, 'debug');
this.actionsQueue = [];
this.collection = null;
selectCollection.call(this)
.then(() => {
this.actionsQueue.forEach((promise) => {
promise();
});
this.actionsQueue.forEach((promise) => promise());
this.actionsQueue = null; // not used anymore

@@ -63,6 +60,6 @@ })

this.logsFile = fs.openSync(config.outputFile, 'a');
this.error = file.bind(this, 'red');
this.warning = file.bind(this, 'yellow');
this.notice = (msg) => { log.call(this, 'blue', msg); file.call(this, 'blue', msg); }; // write into logs and file
this.info = file.bind(this, 'green');
this.error = writeIntoFile.bind(this, 'red');
this.warning = writeIntoFile.bind(this, 'yellow');
this.notice = (msg) => { log.call(this, 'blue', msg); writeIntoFile.call(this, 'blue', msg); }; // write into logs and file
this.info = writeIntoFile.bind(this, 'green');
this.debug = nothing;

@@ -121,9 +118,10 @@ }

if(this.collection)
this.collection.drop();
return this.collection.drop();
else {
const fct = () => { this.collection.drop() };
const fct = () => { this.collection.drop(); };
this.actionsQueue.push(fct.bind(this));
return Promise.resolve();
}
}
if(this.logsFile) {
else if(this.logsFile) {
fs.closeSync(this.logsFile);

@@ -133,2 +131,13 @@ this.logsFile = fs.openSync(this.config.outputFile, 'w');

}
disconnect() {
if(this.config.outputCollection) {
if(this.collection)
this.db.close();
else {
const fct = () => { this.db.close(); };
this.actionsQueue.push(fct.bind(this));
}
}
}
};

@@ -146,7 +155,7 @@

function file(color, msg) {
fs.write(this.logsFile, '<div style="color: ' + color + '">' + formatMessage(msg, this.name) + '</div>');
function writeIntoFile(color, msg) {
fs.writeSync(this.logsFile, '<div style="color: ' + color + '">' + formatMessage(msg, this.name) + '</div>');
}
function db(level, msg) {
function writeIntoDabase(level, msg) {
const doc = {date: Date.now(), level: level, module: this.name, content: msg};

@@ -177,5 +186,6 @@ if(this.collection)

return mongo.connect('mongodb://' + login + ':' + password + '@localhost:27017/' + database)
return mongo.connect('mongodb://' + login + ':' + password + '@127.0.0.1:27017/' + database)
.then((db) => {
return db.collection(this.config.outputCollection);
this.db = db;
return db.createCollection(this.config.outputCollection) // not created if already exists
})

@@ -185,4 +195,4 @@ .then((collection) => {

return this.collection.indexExists({date: -1})
.catch(this.collection.createIndex.bind(this.collection, {date: -1}));
.catch(this.collection.createIndex.bind(this.collection, {date: -1}))
});
}
{
"name": "@coya/logs",
"version": "0.2.1",
"version": "0.2.2",
"description": "Logs service",

@@ -5,0 +5,0 @@ "main": "logs.js",

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