Skip to content

Instantly share code, notes, and snippets.

@jobala
Last active March 5, 2017 08:56
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 jobala/0b3ac8f5a8ddafc1b7d00e1cda60384f to your computer and use it in GitHub Desktop.
Save jobala/0b3ac8f5a8ddafc1b7d00e1cda60384f to your computer and use it in GitHub Desktop.
A Singleton Logger Class
let instance = null;
class Logger {
constructor() {
this.time = new Date();
}
log(message) {
console.log(`Loggin this ${message} at ${this.time}`);
}
static getInstance() {
if (!instance) {
instance = new Logger();
}
return instance;
}
}
export default Logger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment