Last active
March 5, 2017 08:56
-
-
Save jobala/0b3ac8f5a8ddafc1b7d00e1cda60384f to your computer and use it in GitHub Desktop.
A Singleton Logger Class
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
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