Skip to content

Instantly share code, notes, and snippets.

@mark-schaal
Created April 7, 2019 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mark-schaal/682143ee3cef914981140891e0e2812e to your computer and use it in GitHub Desktop.
Save mark-schaal/682143ee3cef914981140891e0e2812e to your computer and use it in GitHub Desktop.
Example custom extension of console logging in Typescript
import chalk from 'chalk';
export const info = (...args: any[]) => {
const [first, ...rest] = args;
const label = chalk.bold.green;
const message = chalk.white;
console.info(label(first), message(...rest));
};
export const warn = (...args: any[]) => {
const [first, ...rest] = args;
const label = chalk.bold.yellow;
const message = chalk.white;
console.warn(label(first), message(...rest));
};
export const error = (...args: any[]) => {
const [first, ...rest] = args;
const label = chalk.bold.red;
const message = chalk.white;
console.error(label(first), message(...rest));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment