UNPKG

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

62 lines (61 loc) 2.09 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { CustomLogger: () => CustomLogger }); module.exports = __toCommonJS(src_exports); 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); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CustomLogger }); //# sourceMappingURL=index.js.map