Beautiful & Customizable log messages in your terminal ❤️
npm install --save xa
Default logger is usign only stdoutHandler which accepts these types of logging
-
info: (label, message)
-
loading: (label, message)
-
warn: (label, message)
-
experimental: (label, message)
-
on: (label, message)
-
off: (label, message)
-
error: (message)
See example.js file.
const xa = require("xa");
xa.info("SUCCESS", "Finished converting file!");
xa.warn(
'WARN',
`This module is deprecated! Read more: ${xa.link('http://example.com')}`
);
xa uses chalk for colorful output, so you can customize technically every color 🦄
Logger({
handlers: [
stdoutHandler({
info: "magenta",
error: "blue"
})
]
});
Handlers are functions that are called when you are logging something. You are able to use predefined one or you can create it by your own like this:
function mineHandler(options = defaultOptions) {
return (type, label, message) => {
switch (type) {
case "error":
DB.insert({
into: "errors",
date: new Date(),
message,
label
});
break;
default:
DB.insert({
into: "logs",
date: new Date(),
message,
label
});
break;
}
};
}
stdoutHandler accepts object with names of acceptable log methods and their display color as values.
const stdoutHandlerOptions = {
error: "red",
experimental: "magenta",
info: "green",
loading: "blue",
off: "gray",
on: "white",
warn: "yellow"
};
- Jamen Marzonie for providing package name!
MIT © Antoni Kepinski