Created
April 7, 2019 23:25
-
-
Save mark-schaal/682143ee3cef914981140891e0e2812e to your computer and use it in GitHub Desktop.
Example custom extension of console logging in Typescript
This file contains 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 characters
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