Created
May 8, 2021 16:54
-
-
Save erkanzileli/624dc1a89aa499e93c9c84e2745d9c66 to your computer and use it in GitHub Desktop.
i just tried tag functions
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
const additionalFields = {}; | |
const logger = { | |
info: loggerWithLevel("info"), | |
error: loggerWithLevel("error"), | |
debug: loggerWithLevel("debug"), | |
}; | |
function loggerWithLevel(level) { | |
return function log(strings, ...keys) { | |
const logBody = { | |
message: strings.join(""), | |
timestamp: new Date().getTime(), | |
level, | |
}; | |
console.log(JSON.stringify(logBody)); | |
}; | |
} | |
logger.info`Process is successfull with id: ${1}`; | |
logger.error`Process is successfull`; | |
logger.debug`Process is successfull`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment