New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.1 to 0.1.2

47

logs.js

@@ -36,3 +36,3 @@ const colors = require('colors');

if(config.logsCollectionName) {
this.docsQueue = [];
this.promisesQueue = [];
this.collectionIsSelected = false;

@@ -51,6 +51,6 @@ this.error = db.bind(this, 'error');

this.collectionIsSelected = true;
this.docsQueue.forEach((doc) => {
Database.addDocs(config.logsCollectionName, doc);
this.promisesQueue.forEach((promise) => {
promise();
});
this.docsQueue = [];
this.promisesQueue = [];
});

@@ -79,3 +79,3 @@ }

this.info = log.bind(this, 'green');
this.debug = log.bind(this, 'white');
this.debug = config.executionMode == DEBUG_MODE ? log.bind(this, 'white') : nothing;
}

@@ -86,6 +86,22 @@

getLogs(callback) {
fs.readFile(this.config.logsFilePath, function(err, data) {
data = '<html><body style=\'display: flex; flex-direction: column-reverse;\'>' + data + '</body></html>';
callback(err, data);
getLogs(limit) {
return new Promise((resolve, reject) => {
if(this.config.logsCollectionName) {
if(!this.collectionIsSelected)
return reject('Collection not selected.');
Database.getCursor(config.jobsCollection, query).sort({date: -1}).limit(limit)
.then(resolve)
.catch(reject);
}
else if(this.logsFile) {
fs.readFile(this.config.logsFilePath, (err, data) => {
if(err)
reject(err);
else
resolve('<html><body style=\'display: flex; flex-direction: column-reverse;\'>' + data + '</body></html>');
});
}
else
reject('No logs.');
});

@@ -95,4 +111,8 @@ }

clear() {
if(this.config.logsCollectionName)
Database.deleteDocsByPattern(this.config.logsCollectionName, {});
if(this.config.logsCollectionName) {
if(this.collectionIsSelected)
Database.deleteDocsByPattern(this.config.logsCollectionName, {});
else
this.promisesQueue.push(Database.deleteDocsByPattern.bind(null, this.config.logsCollectionName, {}));
}
if(this.logsFile) {

@@ -121,3 +141,6 @@ fs.closeSync(this.logsFile);

const doc = {date: Date.now(), level: level, module: this.name, content: msg};
this.collectionIsSelected ? Database.addDocs(this.config.logsCollectionName, doc) : this.docsQueue.push(doc);
if(this.collectionIsSelected)
Database.addDocs(this.config.logsCollectionName, doc);
else
this.promisesQueue.push(Database.addDocs.bind(null, this.config.logsCollectionName, doc));
}

@@ -124,0 +147,0 @@

{
"name": "@coya/logs",
"version": "0.1.1",
"version": "0.1.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