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.3.0 to 1.3.1

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.extend(this.options,t),this.setContext(this.options.context),this.setTimestampFormat(this.options.timestamp.format),this}setName(e){return this.name=e,this}setContext(e){return"string"==typeof e?this.options.context=e:e&&e.constructor&&(this.options.context=e.constructor.name),this}setLogLevel(e){return"string"==typeof e&&(e=Logger.level.stringmap.get(e)),Logger.level.isValidLevel(e)?(this.options.level=e,this):(console.error("Logger.setLogLevel: invalid log level"),this)}setTimestamp(e){return Object.extend(this.options.timestamp,e),this.setTimestampFormat(this.options.timestamp.format),this}setTimestampState(e){return this.options.timestamp.state=e,this}setTimestampFormat(e){if("string"==typeof e&&(e=Logger.timestamp.stringmap.get(e)),!Logger.timestamp.isValidTimestamp(e))return console.error("Logger.setTimestampFormat: invalid timestamp"),this;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 o="";return this.options.timestamp.state&&(o+=this.appendTimestamp()),o+=`[${Logger.level.string[t]}] `,o+=`[${this.name}] `,this.options.context&&(o+=`[${this.options.context}] `),"string"==typeof e&&(o+=e),o}log(e,t=this.options.level){if(t<this.options.level)return!1;let o=this.createMessage(e,t);return"string"==typeof e?console.log(o):(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.level.stringmap=(new Map).set("verbose",Logger.level.verbose).set("debug",Logger.level.debug).set("info",Logger.level.info).set("warning",Logger.level.warning).set("error",Logger.level.error),Logger.level.isValidLevel=function(e){return e>=Logger.level.verbose&&e<=Logger.level.error},Logger.timestamp={utc:0,locale:1,localetime:2,localedate:3},Logger.timestamp.stringmap=(new Map).set("utc",Logger.timestamp.utc).set("locale",Logger.timestamp.locale).set("localetime",Logger.timestamp.localetime).set("localedate",Logger.timestamp.localedate),Logger.timestamp.isValidTimestamp=function(e){return e>=Logger.timestamp.utc&&e<=Logger.timestamp.localedate},"function"!=typeof Object.extend&&(Object.extend=function(){for(let e=1;e<arguments.length;e++)for(let t in arguments[e])arguments[e].hasOwnProperty(t)&&("object"==typeof arguments[0][t]&&"object"==typeof arguments[e][t]?Object.extend(arguments[0][t],arguments[e][t]):arguments[0][t]=arguments[e][t]);return arguments[0]}),"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.extend(this.options,t),this.setContext(this.options.context),this.setTimestampFormat(this.options.timestamp.format),this}setName(e){return this.name=e,this}setContext(e){return"string"==typeof e?this.options.context=e:e&&e.constructor&&(this.options.context=e.constructor.name),this}setLogLevel(e){return"string"==typeof e&&(e=Logger.level.stringmap.get(e)),Logger.level.isValidLevel(e)?(this.options.level=e,this):(console.error("Logger.setLogLevel: invalid log level"),this)}setTimestamp(e){return Object.extend(this.options.timestamp,e),this.setTimestampFormat(this.options.timestamp.format),this}setTimestampState(e){return this.options.timestamp.state=e,this}setTimestampFormat(e){if("string"==typeof e&&(e=Logger.timestamp.stringmap.get(e)),!Logger.timestamp.isValidTimestamp(e))return console.error("Logger.setTimestampFormat: invalid timestamp"),this;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 o="";return this.options.timestamp.state&&(o+=this.appendTimestamp()),o+=`[${Logger.level.string[t]}] `,o+=`[${this.name}] `,this.options.context&&(o+=`[${this.options.context}] `),"string"==typeof e&&(o+=e),o}log(e,t=this.options.level){if(t<this.options.level)return!1;let o=this.createMessage(e,t);return"string"==typeof e?console.log(o):(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.level.stringmap=(new Map).set("verbose",Logger.level.verbose).set("debug",Logger.level.debug).set("info",Logger.level.info).set("warning",Logger.level.warning).set("error",Logger.level.error),Logger.level.isValidLevel=function(e){return e>=Logger.level.verbose&&e<=Logger.level.error},Logger.timestamp={utc:0,locale:1,localetime:2,localedate:3},Logger.timestamp.stringmap=(new Map).set("utc",Logger.timestamp.utc).set("locale",Logger.timestamp.locale).set("localetime",Logger.timestamp.localetime).set("localedate",Logger.timestamp.localedate),Logger.timestamp.isValidTimestamp=function(e){return e>=Logger.timestamp.utc&&e<=Logger.timestamp.localedate},"function"!=typeof Object.extend&&(Object.extend=function(){for(let e=1;e<arguments.length;e++)for(let t in arguments[e])if(arguments[e].hasOwnProperty(t)){if(!arguments[0])continue;"object"==typeof arguments[0][t]&&"object"==typeof arguments[e][t]?Object.extend(arguments[0][t],arguments[e][t]):arguments[0][t]=arguments[e][t]}return arguments[0]}),"undefined"!=typeof module&&(module.exports=Logger);
{
"name": "@voliware/logger",
"version": "1.3.0",
"version": "1.3.1",
"description": "A tiny Javascript logger with levels and several options. Supports Node and all modern Browsers",

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

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

if(arguments[i].hasOwnProperty(key)) {
if(!arguments[0]){
continue;
}
if (typeof arguments[0][key] === 'object' && typeof arguments[i][key] === 'object') {

@@ -371,0 +374,0 @@ Object.extend(arguments[0][key], arguments[i][key]);

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