Created
April 25, 2019 21:21
-
-
Save vinifig/fa0e3bb433d00f79b80d36491cfe5ce2 to your computer and use it in GitHub Desktop.
log system prototype based on aspect oriented programming
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
function fxabc (...params) { return params } | |
let fxabcArrow = (...params) => { throw new Error(JSON.stringify(params)) } | |
let runnerOperations = { | |
logger: (id) => | |
(message) => | |
console.log(`${id} - ${message}`), | |
run (fx, ...params) { | |
let logger = this.logger(Date.now()); | |
logger(`running ${fx.name} with parameters: [${params.join(", ")}]`); | |
try { | |
let response = fx(...params); | |
logger(`response: ${response}`); | |
} catch(e) { | |
logger(`error: ${e}`); | |
} | |
} | |
} | |
runnerOperations.run(fxabc, 1, 2, 3, 4); | |
runnerOperations.run(fxabcArrow, 1, 2, 3, 4, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment