winston 'handleExceptions: true' регистрируется дважды - PullRequest
0 голосов
/ 19 марта 2019

Существует только один транспорт, добавленный так:

winston.add(winston.createLogger({
    transports: [
        new winston.transports.Console({
            handleExceptions: true,
            format: winston.format.combine(
                winston.format.simple()
            ),
        }),
    ]
}));

Когда из index.js выдается новая ошибка:
throw new Error('++++ I will log twice ++++')
приведет к двум отдельным журналам!

Я тоже пробовал transport.File({ ... }), но результат тот же.

Обновление: Как @ terry-lennox , упомянутый в его ответе , вывод выглядит примерно так:

error: uncaughtException: ++++ I will log twice ++++
Error: ++++ I will log twice ++++
    at Object.
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
error: uncaughtException: ++++ I will log twice ++++
Error: ++++ I will log twice ++++
    at Object.
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

версии настройки системы:

OS: Windows 10 v1803
NodeJS: 10.14.1
express: 4.16.4
winston: 3.2.1

1 Ответ

0 голосов
/ 19 марта 2019

Это то поведение, которое вы видите:

error: uncaughtException: ++++ I will log twice ++++
Error: ++++ I will log twice ++++
    at Object.
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

Или вы видите это повторное?

...