-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (26 loc) · 784 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
- Create proxy to add timestamp to console object methods
*/
// Proxy using object literal
class ConsoleProxy {
constructor(consoleObject){
this.consoleObject = consoleObject
}
log(message){
return this.consoleObject.log(`${new Date().toISOString()} ${message}`)
}
error(message){
return this.consoleObject.error(`${new Date().toISOString()} ${message}`)
}
debug(message){
return this.consoleObject.debug(`${new Date().toISOString()} ${message}`)
}
info(message){
return this.consoleObject.info(`${new Date().toISOString()} ${message}`)
}
}
const consoleProxy = new ConsoleProxy(console)
consoleProxy.log("message")
consoleProxy.error("err")
consoleProxy.debug("debug")
consoleProxy.info("info")