react-native-custom-console
Version:
This library is very useful to make the console more redable manageble with different type of logging like warn, error, info, or debug. now you will say there is inbuild console of js provide all this methods but if tried out this library it will be get t
37 lines • 1.09 kB
JavaScript
// src/index.ts
var LogColor = {
error: 31,
success: 32,
warn: 33,
info: 34,
debug: 97
};
var formatTime = (date) => {
let hours = date.getHours();
const minutes = date.getMinutes();
const seconds = date.getSeconds();
const ampm = hours >= 12 ? "PM" : "AM";
hours = hours % 12 || 12;
return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")} ${ampm}`;
};
var formatDate = (date) => {
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
};
var CheckMode = {
development: true,
production: false
};
var CustomLogger = ({ messg, from, type, mode = "development" }) => {
if (CheckMode[mode]) {
const now = /* @__PURE__ */ new Date();
const time = formatTime(now);
const date = formatDate(now);
const FormMessg = `${date} | ${time} | screen: ${from}
Message: ${JSON.stringify(messg, void 0, 4)}`;
console.log(`\x1B[${LogColor[type]}m%s\x1B[0m`, FormMessg);
}
};
export {
CustomLogger
};
//# sourceMappingURL=index.mjs.map