Created
March 12, 2024 12:29
-
-
Save kcmr/f95fe3a469da8cdf68c28c9f5c42a1ae to your computer and use it in GitHub Desktop.
Revisions
-
kcmr created this gist
Mar 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ export const logger = (function logger() { const red = (text) => `\u001B[31m${text}\u001B[0m` const yellow = (text) => `\u001B[33m${text}\u001B[0m` const green = (text) => `\u001B[32m${text}\u001B[0m` function mapConsoleArgumentsWithColor(method, color) { return function (...arguments_) { console[method](...arguments_.map((t) => color(t))) } } return { info: console.log, error: mapConsoleArgumentsWithColor('error', red), warn: mapConsoleArgumentsWithColor('warn', yellow), success: mapConsoleArgumentsWithColor('log', green), } })()