Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erkanzileli/624dc1a89aa499e93c9c84e2745d9c66 to your computer and use it in GitHub Desktop.
Save erkanzileli/624dc1a89aa499e93c9c84e2745d9c66 to your computer and use it in GitHub Desktop.
i just tried tag functions
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