Skip to content

Commit

Permalink
feat: add ability for tags to be functions
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleRoss committed Apr 12, 2021
1 parent 201a6fe commit 459380f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/LogMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ class LogMessage {
const opts = this[symbols.OPTS];
const tags = [].concat(opts.tags, this[symbols.LOG].tags);

return tags.map(tag => {
if(typeof tag === 'function') {
return tag.call(this, {
level: this.level,
meta: this.meta,
options: opts
});
}

return tag;
}).filter(tag => tag !== null && tag !== undefined && tag !== '');
Expand Down

0 comments on commit 459380f

Please sign in to comment.