mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 18:43:21 +00:00
filter out error logs in buffer
This commit is contained in:
parent
cb22e98766
commit
1809d6e403
2 changed files with 17 additions and 6 deletions
|
@ -171,8 +171,10 @@ const Logger = module.exports = {
|
|||
},
|
||||
|
||||
error(attributes, message, ...args) {
|
||||
if (this.ringBuffer !== null) {
|
||||
attributes.logBuffer = this.ringBuffer.records
|
||||
if (this.ringBuffer !== null && Array.isArray(this.ringBuffer.records)) {
|
||||
attributes.logBuffer = this.ringBuffer.records.filter(function (record) {
|
||||
return record.level !== 50
|
||||
})
|
||||
}
|
||||
this.logger.error(attributes, message, ...Array.from(args))
|
||||
if (this.raven != null) {
|
||||
|
|
|
@ -334,6 +334,10 @@ describe('LoggingManager', function() {
|
|||
},
|
||||
{
|
||||
msg: 'log 2'
|
||||
},
|
||||
{
|
||||
level: 50,
|
||||
msg: 'error'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
@ -350,10 +354,15 @@ describe('LoggingManager', function() {
|
|||
process.env['LOG_RING_BUFFER_SIZE'] = undefined
|
||||
})
|
||||
|
||||
it('should include buffered logs in error log', function() {
|
||||
this.mockBunyanLogger.error.lastCall.args[0].logBuffer.should.equal(
|
||||
this.logBufferMock
|
||||
)
|
||||
it('should include buffered logs in error log and filter out error logs in buffer', function() {
|
||||
this.mockBunyanLogger.error.lastCall.args[0].logBuffer.should.deep.equal([
|
||||
{
|
||||
msg: 'log 1'
|
||||
},
|
||||
{
|
||||
msg: 'log 2'
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue