Skip to content

Instantly share code, notes, and snippets.

@wzr1337
Created August 16, 2018 07:28
Show Gist options
  • Save wzr1337/226d6b43a38f335492897fec1df11363 to your computer and use it in GitHub Desktop.
Save wzr1337/226d6b43a38f335492897fec1df11363 to your computer and use it in GitHub Desktop.
A small colorful, timestamping typescript logger class
import { Logger } from "./logger";
Logger.log("just logging");
export class Logger {
public static log(...args: any[]) {
console.log(`[${new Date(Date.now())}]`, ...args);
}
public static debug(...args: any[]) {
console.log(`\x1b[33m[${new Date(Date.now())}]\x1b[0m`, ...args);
}
public static error(...args: any[]) {
console.log(`\x1b[31m[${new Date(Date.now())}]\x1b[0m`, ...args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment