Skip to content

Commit

Permalink
avoid to use shallow copy and it fix winstonjs#1775
Browse files Browse the repository at this point in the history
  • Loading branch information
debadutta98 committed Oct 29, 2022
1 parent 8769d47 commit 79c202a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/winston/create-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ module.exports = function (opts = {}) {
if (args.length === 1) {
const [msg] = args;
const info = msg && msg.message && msg || { message: msg };
info.level = info[LEVEL] = level;
self._addDefaultMeta(info);
self.write(info);
const cloneInfo = Object.assign(Object.create(info), info)
cloneInfo.level = cloneInfo[LEVEL] = level;
self._addDefaultMeta(cloneInfo);
self.write(cloneInfo);
return (this || logger);
}

Expand Down
3 changes: 0 additions & 3 deletions test/unit/winston/logger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ describe('Logger Instance', function () {

const logger = helpers.createLogger(function (info) {
assume(info).instanceOf(Error);
assume(info).equals(err);
done();
});

Expand Down Expand Up @@ -772,7 +771,6 @@ describe('Logger Instance', function () {
const err = new Error('test');
const logger = helpers.createLogger(function (info) {
assume(info).instanceOf(Error);
assume(info).equals(err);
done();
});

Expand Down Expand Up @@ -959,7 +957,6 @@ describe('Logger Instance', function () {
const err = new Error('test');
const logger = helpers.createLogger(function (info) {
assume(info).instanceOf(Error);
assume(info).equals(err);
done();
});

Expand Down

0 comments on commit 79c202a

Please sign in to comment.