1.0.0 • Published 3 years ago

@helper-modules/log v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

@helper-modules/log

Easily Log to Console

Installation

npm i @helper-modules/log

Usage

Syntex

log(
    data: any,
    statusColor: String,
    prefix: String
);
  • Params:
    • data:
      • type: [Object|String|Array]
      • default: ""
    • statusColor:
      • type: String
      • default: info
      • usage: Allows to change the color of Hightlight and log prefix
      • allowed: log | success | info | warn | error | dark | maganta | blue
    • prefix
      • type: String
      • default: <defaultPrefix>

Common Usage

const log = require("@helper-modules/log");
// or
const { log } = require("@helper-modules/all");

log("Hello World")

image


  • Other statusColors
log("Hello World", "log");
log("Hello World", "success");
log("Hello World", "warn");
log("Hello World", "error");
log("Hello World", "dark");
log("Hello World", "maganta");
log("Hello World", "blue");

image


  • Javascript Object
log(
    {
        name: "Henil",
        age: 16
    }
)

image


  • Highlighting
log("Hello {World}");
log("Hello {World}", "log");
log("Hello {World}", "success");
log("Hello {World}", "warn");
log("Hello {World}", "error");
log("Hello {World}", "dark");
log("Hello {World}", "maganta");
log("Hello {World}", "blue");

image

NOTE: Text inside {} will be colored same as provided statusColor


  • Custom Prefix
log("Hello World", "warn", "[MY-PREFIX]")

image


  • Default Prefix
log.setDefaultPrefix("[SYSTEM]");

log("With New Prefix!", "success")

image


Log Prevention

If you want to Prevent Log to console you can set LOG key to false on your environment variables. Now Even if you call log function nothing will be logged to console. This helps for production builds.

LOG=false
log("This will not be Logged")

After Setting LOG to false; log module is kind of useless as it simply returns null.