mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
replace bunyan error serializer with custom one (#14)
This commit is contained in:
parent
888badbf0c
commit
6b3e7e4ffc
3 changed files with 22 additions and 2 deletions
|
@ -1,5 +1,20 @@
|
|||
const bunyan = require('bunyan')
|
||||
const request = require('request')
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
||||
// bunyan error serializer
|
||||
const errSerializer = function (err) {
|
||||
if (!err || !err.stack)
|
||||
return err;
|
||||
return {
|
||||
message: err.message,
|
||||
name: err.name,
|
||||
stack: OError.getFullStack(err),
|
||||
info: OError.getFullInfo(err),
|
||||
code: err.code,
|
||||
signal: err.signal
|
||||
};
|
||||
};
|
||||
|
||||
const Logger = module.exports = {
|
||||
initialize(name) {
|
||||
|
@ -28,7 +43,11 @@ const Logger = module.exports = {
|
|||
}
|
||||
this.logger = bunyan.createLogger({
|
||||
name,
|
||||
serializers: bunyan.stdSerializers,
|
||||
serializers: {
|
||||
err: errSerializer,
|
||||
req: bunyan.stdSerializers.req,
|
||||
res: bunyan.stdSerializers.res
|
||||
},
|
||||
streams: loggerStreams
|
||||
})
|
||||
if (this.isProduction) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"lint": "eslint -f unix ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@overleaf/o-error": "^2.0.0",
|
||||
"bunyan": "1.8.12",
|
||||
"raven": "1.1.3",
|
||||
"request": "2.88.0"
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('LoggingManager', function() {
|
|||
once: sinon.stub().yields()
|
||||
}
|
||||
this.LoggingManager = SandboxedModule.require(modulePath, {
|
||||
globals: { console },
|
||||
globals: { console, process },
|
||||
requires: {
|
||||
bunyan: (this.Bunyan = {
|
||||
createLogger: sinon.stub().returns(this.mockBunyanLogger),
|
||||
|
|
Loading…
Reference in a new issue