1.0.0 • Published 3 years ago
@helper-modules/log v1.0.0
@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:
""
- type:
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
- type:
prefix
- type:
String
- default:
<defaultPrefix>
- type:
Common Usage
const log = require("@helper-modules/log");
// or
const { log } = require("@helper-modules/all");
log("Hello World")
- Other
statusColor
s
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");
- Javascript Object
log(
{
name: "Henil",
age: 16
}
)
- 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");
NOTE: Text inside {}
will be colored same as provided statusColor
- Custom Prefix
log("Hello World", "warn", "[MY-PREFIX]")
- Default Prefix
log.setDefaultPrefix("[SYSTEM]");
log("With New Prefix!", "success")
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
.
1.0.0
3 years ago