Last active
April 20, 2018 04:42
-
-
Save SukantGujar/5067a1adb8491b6fc43288f1cc089806 to your computer and use it in GitHub Desktop.
Prepack experiment index.js
This file contains hidden or 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 reduce from "ramda/src/reduce"; | |
import keys from "ramda/src/keys"; | |
const log = function(target) { | |
return function(level) { | |
return function(message) { | |
return target[level](message); | |
}; | |
}; | |
}; | |
class Logger { | |
constructor(target) { | |
this.LOG_STATUS_FLAGS = reduce( | |
(p, v) => Object.assign({}, p, { [v]: v }), | |
{}, | |
[ | |
"ERROR", | |
"WARN", | |
"INFO", | |
"DEBUG", | |
"SILLY" | |
].map(x => x.toLowerCase()) | |
); | |
this.target = target; | |
reduce( | |
(p, v) => Object.assign(p, { [v]: log(this.target)(v) }), | |
this, | |
keys(this.LOG_STATUS_FLAGS) | |
); | |
} | |
} | |
module.exports = Object.assign({}, new Logger(console)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment