Skip to content

Commit

Permalink
update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
debadutta98 committed Oct 30, 2022
1 parent 5e754ef commit 7f6ac39
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 98 deletions.
2 changes: 1 addition & 1 deletion lib/winston/create-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = function (opts = {}) {
if (args.length === 1) {
const [msg] = args;
const info = msg && msg.message && msg || { message: msg };
const cloneInfo = Object.assign(Object.create(info), info)
const cloneInfo = Object.assign(Object.create(info), info);
cloneInfo.level = cloneInfo[LEVEL] = level;
self._addDefaultMeta(cloneInfo);
self.write(cloneInfo);
Expand Down
9 changes: 5 additions & 4 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,17 @@ class Logger extends Transform {
// Yo dawg, I heard you like levels ... seriously ...
// In this context the LHS `level` here is actually the `info` so read
// this as: info[LEVEL] = info.level;
level[LEVEL] = level.level;
this._addDefaultMeta(level);
this.write(level);
const cloneLevel = Object.assign(Object.create(level), level);
cloneLevel[LEVEL] = level.level;
this._addDefaultMeta(cloneLevel);
this.write(cloneLevel);
return this;
}

// Slightly less hotpath, but worth optimizing for.
if (arguments.length === 2) {
if (msg && typeof msg === 'object') {
const cloneMsg=Object.assign(Object.create(msg), msg)
const cloneMsg = Object.assign(Object.create(msg), msg);
cloneMsg[LEVEL] = cloneMsg.level = level;
this._addDefaultMeta(cloneMsg);
this.write(cloneMsg);
Expand Down
Loading

0 comments on commit 7f6ac39

Please sign in to comment.