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.1.1 to 1.2.0

2

dist/logger.min.js

@@ -1,1 +0,1 @@

class Logger{constructor(e,t={}){return this.name=e,this.options={level:Logger.level.info,timestamp:{state:!1,format:Logger.timestamp.locale},context:null},Object.assign(this.options,t),this.setTimestampFormat(this.options.timestamp.format),this}setContext(e){return this.options.context=e,this}setLogLevel(e){return this.options.level=e,this}setTimestamp(e){return this.options.timestamp=e,this.setTimestampFormat(this.options.timestamp.format),this}setTimestampFormat(e){switch(e){case Logger.timestamp.utc:this.appendTimestamp=this.appendUtcTimestamp;break;case Logger.timestamp.localedate:this.appendTimestamp=this.appendLocaleDateTimestamp;break;case Logger.timestamp.localetime:this.appendTimestamp=this.appendLocaleTimeTimestamp;break;case Logger.timestamp.locale:default:this.appendTimestamp=this.appendLocaleTimestamp}return this}setCustomTimestampFormat(e){return this.appendTimestamp=e,this}appendUtcTimestamp(){return`[${(new Date).toUTCString()}] `}appendLocaleTimestamp(){return`[${(new Date).toLocaleString()}] `}appendLocaleTimeTimestamp(){return`[${(new Date).toLocaleTimeString()}] `}appendLocaleDateTimestamp(){return`[${(new Date).toLocaleDateString()}] `}createMessage(e,t){let s="";return this.options.timestamp.state&&(s+=this.appendTimestamp()),s+=`[${Logger.level.string[t]}] `,s+=`[${this.name}] `,this.options.context&&(s+=`[${this.options.context}] `),"string"==typeof e&&(s+=e),s}log(e,t=this.options.level){if(t<this.options.level)return!1;let s=this.createMessage(e,t);return"string"==typeof e?console.log(s):(console.log("logging object"),console.log(e)),!0}verbose(e){return this.log(e,Logger.level.verbose)}debug(e){return this.log(e,Logger.level.debug)}info(e){return this.log(e,Logger.level.info)}warning(e){return this.log(e,Logger.level.warning)}error(e){return this.log(e,Logger.level.error)}}Logger.level={verbose:0,debug:1,info:2,warning:3,error:4,string:["VRB","DBG","INF","WRN","ERR"]},Logger.timestamp={utc:0,locale:1,localetime:2,localedate:3},"undefined"!=typeof module&&(module.exports=Logger);
class Logger{constructor(e,t={}){return this.name=e,this.options={level:Logger.level.info,timestamp:{state:!1,format:Logger.timestamp.locale},context:null},Object.assign(this.options,t),this.setTimestampFormat(this.options.timestamp.format),this}setName(e){return this.name=e,this}setContext(e){return this.options.context=e,this}setLogLevel(e){return this.options.level=e,this}setTimestamp(e){return this.options.timestamp=e,this.setTimestampFormat(this.options.timestamp.format),this}setTimestampFormat(e){switch(e){case Logger.timestamp.utc:this.appendTimestamp=this.appendUtcTimestamp;break;case Logger.timestamp.localedate:this.appendTimestamp=this.appendLocaleDateTimestamp;break;case Logger.timestamp.localetime:this.appendTimestamp=this.appendLocaleTimeTimestamp;break;case Logger.timestamp.locale:default:this.appendTimestamp=this.appendLocaleTimestamp}return this}setCustomTimestampFormat(e){return this.appendTimestamp=e,this}appendUtcTimestamp(){return`[${(new Date).toUTCString()}] `}appendLocaleTimestamp(){return`[${(new Date).toLocaleString()}] `}appendLocaleTimeTimestamp(){return`[${(new Date).toLocaleTimeString()}] `}appendLocaleDateTimestamp(){return`[${(new Date).toLocaleDateString()}] `}createMessage(e,t){let s="";return this.options.timestamp.state&&(s+=this.appendTimestamp()),s+=`[${Logger.level.string[t]}] `,s+=`[${this.name}] `,this.options.context&&(s+=`[${this.options.context}] `),"string"==typeof e&&(s+=e),s}log(e,t=this.options.level){if(t<this.options.level)return!1;let s=this.createMessage(e,t);return"string"==typeof e?console.log(s):(console.log("logging object"),console.log(e)),!0}verbose(e){return this.log(e,Logger.level.verbose)}debug(e){return this.log(e,Logger.level.debug)}info(e){return this.log(e,Logger.level.info)}warning(e){return this.log(e,Logger.level.warning)}error(e){return this.log(e,Logger.level.error)}}Logger.level={verbose:0,debug:1,info:2,warning:3,error:4,string:["VRB","DBG","INF","WRN","ERR"]},Logger.timestamp={utc:0,locale:1,localetime:2,localedate:3},"undefined"!=typeof module&&(module.exports=Logger);
{
"name": "@voliware/logger",
"version": "1.1.1",
"version": "1.2.0",
"description": "A tiny Javascript logger with levels and several options. Supports Node and all modern Browsers",

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

@@ -57,2 +57,12 @@ /**

/**
* Set the logger name, which appears
* as the first item in the message after timestamp.
* @param {string} name
*/
setName(name){
this.name = name;
return this;
}
/**
* Set the logger context.

@@ -59,0 +69,0 @@ * This could be set when printing logs from

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