Skip to content

Instantly share code, notes, and snippets.

@SukantGujar
Last active April 20, 2018 04:42
Show Gist options
  • Save SukantGujar/5067a1adb8491b6fc43288f1cc089806 to your computer and use it in GitHub Desktop.
Save SukantGujar/5067a1adb8491b6fc43288f1cc089806 to your computer and use it in GitHub Desktop.
Prepack experiment index.js
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