Merge pull request #14292 from overleaf/jpa-em-mj-warnings

[logger] forward warnings to logger for all the services

GitOrigin-RevId: f9d0b8c7197e3e14e8abf6bba10136ee785410ed
This commit is contained in:
Jakob Ackermann 2023-08-24 13:26:26 +02:00 committed by Copybot
parent 6b051b260e
commit ddf6ac272d
3 changed files with 13 additions and 11 deletions

View file

@ -149,4 +149,13 @@ const LoggingManager = {
LoggingManager.initialize('default-sharelatex')
function handleWarning(err) {
LoggingManager.warn({ err }, 'Warning details')
}
process.on('warning', handleWarning)
LoggingManager.removeWarningHandler = () => {
process.off('warning', handleWarning)
}
module.exports = LoggingManager

View file

@ -59,6 +59,10 @@ describe('LoggingManager', function () {
this.logger.initializeErrorReporting('test_dsn')
})
afterEach(function () {
this.LoggingManager.removeWarningHandler()
})
describe('initialize', function () {
beforeEach(function () {
this.Bunyan.createLogger.reset()

View file

@ -19,17 +19,6 @@ Events.setMaxListeners(20)
const app = express()
process.on('warning', warning => {
logger.warn(
{
name: warning.name,
message: warning.message,
stack: warning.stack,
},
'Warning details'
)
})
app.use(RequestLogger.middleware)
if (settings.sentry && settings.sentry.dsn) {