UNPKG

modern-api.styledlog

Version:

log content in custom css style based on

28 lines (26 loc) 609 B
// index.ts var output = (level, texts) => { const text = texts.reduce( (acc, [t]) => `${acc}${t}`, "" ); console[level](text, ...texts.map(([_, style]) => style)); }; var styled = (styles) => { return (text) => { return [`%c${text}`, Object.keys(styles).reduce((acc, key) => `${key}:${styles[key]};${acc}`, "")]; }; }; var log = (...texts) => { output("log", texts); }; var warn = (...texts) => { output("warn", texts); }; var error = (...texts) => { output("error", texts); }; var debug = (...texts) => { output("debug", texts); }; export { debug, error, log, styled, warn };