Comparing version 0.0.51 to 0.0.52
63
index.js
@@ -6,21 +6,36 @@ const colors = require("colors"); | ||
const c = { | ||
timestamp : false, | ||
timestampFormat: "", | ||
prefix : "", | ||
writeToFile: true, | ||
filePath: "c.log", //working on | ||
info : (p) => { | ||
Object.keys(c).forEach((key,ind) => { | ||
class clrlg { | ||
constructor() { | ||
this._timestamp = false; | ||
this.timestampFormat= "";; | ||
this.writeToFile= true; | ||
this.filePath= "c.log"; //working on | ||
} | ||
set timestamp(val) { | ||
if(typeof(val) === "boolean") this._timestamp = val; | ||
this.lg(`timestamp = ${this._timestamp}`); | ||
} | ||
get timestamp() { | ||
return this._timestamp; | ||
} | ||
info(p) { | ||
if(this[p]) { | ||
this.lg(`${p} = ${this[p]}`); | ||
return; | ||
} | ||
Object.keys(this).forEach((key,ind) => { | ||
//if(key == p && p != undefined){ | ||
//} | ||
if({}.toString.call(c[key]) != "[object Function]") { | ||
if({}.toString.call(this[key]) != "[object Function]") { | ||
console.log(`${key} = ${c[key]}`); | ||
this.lg(`${key} = ${this[key]}`); | ||
} | ||
}) | ||
}, | ||
lg : (output,r="white") => { | ||
if(c.prefix != "") pfx = `${c.prefix}:`; | ||
if(c.timestamp != false) pfx = `${getTs(c.timestampFormat)}:`; | ||
}; | ||
lg(output,r="white") { | ||
if(this.timestamp !== false) { pfx = `${getTs(this.timestampFormat)}:`} else { pfx = "";} | ||
@@ -31,15 +46,17 @@ | ||
} catch (err) { | ||
console.log(colors.underline(`${output} - invalid color`)); | ||
console.log(colors.underline(`${pfx}${output} - invalid color`)); | ||
} | ||
}, | ||
start : (id) => { | ||
}; | ||
start(id) { | ||
// start timer | ||
c.a = new Date().getTime(); | ||
}, | ||
end : (id) => { | ||
this[id] = new Date().getTime(); | ||
}; | ||
end(id) { | ||
//end time from start to end | ||
let t = new Date().getTime() - c.a; | ||
let t = new Date().getTime() - this[id]; | ||
let elapsed = Math.floor(t / 100) / 10; | ||
if(Math.round(elapsed) == elapsed) { elapsed += '.0'; } | ||
console.log(`time elapsed: ${elapsed} seconds`); | ||
this.lg(`time elapsed: ${elapsed} seconds`,"white"); | ||
} | ||
@@ -60,2 +77,2 @@ } | ||
module.exports = c; | ||
module.exports = clrlg; |
{ | ||
"name": "clrlg", | ||
"version": "0.0.51", | ||
"version": "0.0.52", | ||
"description": "Color Log", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# clrlg | ||
Color Logging | ||
Color Logging with timers and other functionality. | ||
@@ -12,6 +12,10 @@ ##Install | ||
``` | ||
const c = require('clrlg'); | ||
const clrlg = require("clrlg"); | ||
let c = new clrlg(); | ||
c.lg("default color"); | ||
c.timestamp = true; | ||
c.lg("red","red"); | ||
@@ -24,2 +28,3 @@ | ||
c.lg("green","green"); | ||
c.timestamp = false; | ||
@@ -34,10 +39,9 @@ c.lg("magenta","magenta"); | ||
c.lg("fish color","fish"); | ||
c.start("1"); | ||
c.lg("orange","blsddsue"); | ||
setTimeout(()=>{c.end("1")},5500); | ||
c.start("a"); | ||
setTimeout(()=>{c.end("a")},5525); | ||
c.info(); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3344
83
44