Updates
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
declare const LogTypes: readonly ["error", "warning"];
|
||||
type Param = {
|
||||
/**
|
||||
* data to be logged.
|
||||
*/
|
||||
log: any;
|
||||
/**
|
||||
* Log Title. Could be name of function or name of variable
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* Label for the log
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Log type. `error` or `warning` or default
|
||||
*/
|
||||
type?: (typeof LogTypes)[number];
|
||||
/**
|
||||
* Whether to add a time stamp
|
||||
*/
|
||||
addTime?: boolean;
|
||||
};
|
||||
export default function debugLog({ log, label, title, type, addTime }: Param): void;
|
||||
export {};
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = debugLog;
|
||||
const console_colors_1 = require("../console-colors");
|
||||
const LogTypes = ["error", "warning"];
|
||||
function debugLog({ log, label, title, type, addTime }) {
|
||||
const logType = (() => {
|
||||
switch (type) {
|
||||
case "error":
|
||||
return console_colors_1.ccol.FgRed;
|
||||
case "warning":
|
||||
return console_colors_1.ccol.FgYellow;
|
||||
default:
|
||||
return console_colors_1.ccol.FgGreen;
|
||||
}
|
||||
})();
|
||||
let logTxt = `${logType}DEBUG${console_colors_1.ccol.Reset}:::`;
|
||||
const date = new Date();
|
||||
const time = date.toLocaleTimeString("en-US", {
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
second: "numeric",
|
||||
hour12: true,
|
||||
});
|
||||
const logTime = `${date.toLocaleDateString()}][${time}`;
|
||||
if (addTime)
|
||||
logTxt = `${console_colors_1.ccol.BgWhite}[${logTime}]${console_colors_1.ccol.Reset} ` + logTxt;
|
||||
if (title)
|
||||
logTxt += `${console_colors_1.ccol.FgBlue}${title}${console_colors_1.ccol.Reset}::`;
|
||||
if (label)
|
||||
logTxt += `${console_colors_1.ccol.FgWhite}${console_colors_1.ccol.Bright}${label}${console_colors_1.ccol.Reset} =>`;
|
||||
console.log(logTxt, log);
|
||||
}
|
||||
Reference in New Issue
Block a user