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 1.5.3 to 1.6.0

2

package.json
{
"name": "@voliware/logger",
"version": "1.5.3",
"version": "1.6.0",
"description": "A tiny Javascript logger with levels and several options. Supports Node and all modern Browsers",

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

@@ -184,2 +184,5 @@ /**

break;
case Logger.timestamp.numeric:
this.appendTimestamp = this.appendNumericTimestamp
break;
case Logger.timestamp.locale:

@@ -240,6 +243,15 @@ default:

/**
* Append a numerical timestamp.
* eg 1628828513146
* @return {Logger}
*/
appendNumericTimestamp(){
return `[${Date.now()}] `;
}
/**
* Create a log message.
* @param {String} message - message to log
* @param {Number} level - log level
* @return {Logger}
* @return {String}
*/

@@ -400,3 +412,4 @@ createMessage(message, level){

localetime: 2,
localedate: 3
localedate: 3,
numeric
};

@@ -412,3 +425,4 @@

.set("localetime", Logger.timestamp.localetime)
.set("localedate", Logger.timestamp.localedate);
.set("localedate", Logger.timestamp.localedate)
.set("numeric", Logger.timestamp.numeric);

@@ -421,3 +435,3 @@ /**

Logger.timestamp.isValidTimestamp = function(timestamp){
return timestamp >= Logger.timestamp.utc && timestamp <= Logger.timestamp.localedate;
return timestamp >= Logger.timestamp.utc && timestamp <= Logger.timestamp.numeric;
};

@@ -424,0 +438,0 @@

@@ -32,2 +32,3 @@ const Logger = require('./logger');

* @param {String} [options.output.file=""] - a file to save the log to, or blank for none
* @param {Collection} [options.output.mongodb=null] - a reference to a MongoDB collection
* @return {Logger}

@@ -39,3 +40,4 @@ */

console: true,
file: ""
file: "",
mongodb: null
}

@@ -48,2 +50,3 @@ };

this.fileIsValid = this.isValidFilepath(this.options.output.file);
this.mongodb = defaults.mongodb;
return this;

@@ -163,4 +166,29 @@ }

}
/**
* Create a log message.
* Override to insert into mongodb if set.
* @param {String} message - message to log
* @param {Number} level - log level
* @return {String}
*/
createMessage(message, level){
if(this.mongodb){
const doc = {
level: Logger.level.string[level],
message: message,
name: this.name
};
if(this.options.timestamp.state){
doc.time = this.appendTimestamp();
}
if(this.options.context){
doc.context = this.options.context;
}
this.mongodb.insertOne(doc);
}
return super.createMessage(message, level);
}
}
module.exports = NodeLogger;
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