Skip to content

msg is empty on logger.log( 'error' ) #106

@yamii

Description

@yamii

Lapin will log

  • error - when error occurs
  • info - when success
  • warn - when fail

For the error, our logger is integrated to slack in which we can receive real time errors on #error-logs channel. We noticed that msg is empty when it should not be. msg by the way is the msg sent to a certain service for it to consume.

See here where we set msg: https://github.com/sinet/lapin/blob/master/lib/req-res/status.js#L59

And the reason we do deep clone before is that lapin will hang. My hypothesis is - it's because lapin and logger are both using the msg object. So that to disrupt lapin from using the msg object we just cloned the msg object for logger's usage. I think we'll just look into deep merge using Object.assign.

I also read something about deep clone

Warning for Deep Clone

For deep cloning, we need to use other alternatives. This is because Object.assign() copies the property reference when the property being assigned is an object.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Merging_objects

Messages we sent to the consumers are not all objects.

sinet/logger BOT [1:52 PM]  
error
code
----------------
13-012

data
----------------
SequelizeUniqueConstraintError: Validation error
   at Query.formatError (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:316:16)
   at .<anonymous> (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:81:19)
   at emitOne (events.js:96:13)
   at emit (events.js:188:7)
   at Query.handleError (/usr/src/app/node_modules/pg/lib/query.js:125:8)
   at .<anonymous> (/usr/src/app/node_modules/pg/lib/client.js:172:26)
   at emitOne (events.js:96:13)
   at emit (events.js:188:7)
   at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:113:12)
   at emitOne (events.js:96:13)
   at Socket.emit (events.js:188:7)
   at readableAddChunk (_stream_readable.js:177:18)
   at Socket.Readable.push (_stream_readable.js:135:10)
   at TCP.onread (net.js:542:20)

messageType
----------------
req-res.v1.mc-bit.get-by-id

msg
----------------


errorMsg
----------------
Validation error

service
----------------
microcredential-service

hostname
----------------
stmiami202-microcredential-service0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions