Skip to content

Commit

Permalink
feat: add ability to change the key names of the message output
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleRoss committed Apr 12, 2021
1 parent a43b0ae commit 4a71909
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/LogMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ class LogMessage {

/**
* The full log object. This is the object used in logMessage.toJSON() and when the log is written to the console.
* See [Log Output](#log-output) for more information.
* @returns {Object} The full log object.
* @example
* log.info('This is some info').value;
* //=> { _logLevel: 'info', msg: 'This is some info', ... }
*/
get value() {
return { _logLevel: this.level, msg: this.msg, ...this.meta, _tags: this.tags };
const opts = this[symbols.OPTS];
return {
[opts.levelKey]: opts.levelKey ? this.level : undefined,
[opts.messageKey]: this.msg,
...this.meta,
[opts.tagsKey]: opts.tagsKey ? this.tags : undefined
};
}

/**
Expand Down

0 comments on commit 4a71909

Please sign in to comment.