Comparing version 0.4.0 to 0.5.0
@@ -30,2 +30,3 @@ "use strict"; | ||
this.logLevel = options?.logLevel ?? defaultOptions.logLevel; | ||
this.includeMilliseconds = options?.includeMilliseconds ?? false; | ||
} | ||
@@ -59,3 +60,3 @@ log(s, options) { | ||
constructMessage(s, cmd, options) { | ||
let msg = chalk_1.default.cyan(new Date().toUTCString()) + seperator + this.getCMDString(cmd); | ||
let msg = chalk_1.default.cyan(this.getDate()) + seperator + this.getCMDString(cmd); | ||
if (typeof options?.process == "string") | ||
@@ -75,3 +76,3 @@ msg += chalk_1.default.magenta(options.process) + seperator; | ||
constructEntry(s, cmd, options) { | ||
let msg = new Date().toUTCString() + seperator + cmd + seperator; | ||
let msg = this.getDate() + seperator + cmd + seperator; | ||
if (typeof options?.process == "string") | ||
@@ -102,2 +103,5 @@ msg += options.process + seperator; | ||
} | ||
getDate() { | ||
return this.includeMilliseconds ? new Date().toUTCString().replace(" GMT", `.${new Date().getMilliseconds()} GMT`) : new Date().toUTCString(); | ||
} | ||
addCache(log) { | ||
@@ -104,0 +108,0 @@ this.cache.push(log); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const __1 = __importDefault(require("..")); | ||
const debug = __1.default({ maxCacheSize: 10, logLevel: 4 }); | ||
const debug = __1.default({ maxCacheSize: 10, logLevel: 4, includeMilliseconds: true }); | ||
debug.log("this is a log", { | ||
@@ -11,0 +11,0 @@ process: "process", |
{ | ||
"name": "debux", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Easy-to-use library for debugging your code", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -89,2 +89,3 @@ # Debux | ||
logLevel?: level;// which logs should be logged into console directly | ||
includeMilliseconds?: boolean;// whether to include milliseconds in the date string | ||
} | ||
@@ -91,0 +92,0 @@ |
@@ -23,2 +23,3 @@ import chalk from "chalk"; | ||
logLevel?: level; | ||
includeMilliseconds?: boolean; | ||
} | ||
@@ -43,2 +44,3 @@ | ||
private logLevel: number; | ||
private includeMilliseconds: boolean; | ||
constructor(options?: constructOptions) { | ||
@@ -48,2 +50,3 @@ this.maxCacheSize = options?.maxCacheSize ?? defaultOptions.maxCacheSize; | ||
this.logLevel = options?.logLevel ?? defaultOptions.logLevel; | ||
this.includeMilliseconds = options?.includeMilliseconds ?? false; | ||
} | ||
@@ -84,3 +87,3 @@ public log(s: string | null, options?: Options): void { | ||
let msg: string = | ||
chalk.cyan(new Date().toUTCString()) + seperator + this.getCMDString(cmd); | ||
chalk.cyan(this.getDate()) + seperator + this.getCMDString(cmd); | ||
if (typeof options?.process == "string") msg += chalk.magenta(options.process) + seperator; | ||
@@ -96,3 +99,3 @@ if (typeof options?.class == "string") msg += chalk.yellow(options.class) + seperator; | ||
let msg: string = | ||
new Date().toUTCString() + seperator + cmd + seperator; | ||
this.getDate() + seperator + cmd + seperator; | ||
if (typeof options?.process == "string") msg += options.process + seperator; | ||
@@ -119,2 +122,6 @@ if (typeof options?.class == "string") msg += options.class + seperator; | ||
private getDate(): string { | ||
return this.includeMilliseconds ? new Date().toUTCString().replace(" GMT", `.${new Date().getMilliseconds()} GMT`) : new Date().toUTCString(); | ||
} | ||
private addCache(log: string): void { | ||
@@ -121,0 +128,0 @@ this.cache.push(log); |
//@ts-ignore | ||
import debux from ".."; | ||
const debug = debux({ maxCacheSize: 10, logLevel: 4 }); | ||
const debug = debux({ maxCacheSize: 10, logLevel: 4, includeMilliseconds: true }); | ||
@@ -6,0 +6,0 @@ debug.log("this is a log", { |
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
16148
300
102