TomFrost / Bristol

Insanely configurable logging for Node.js
MIT License
113 stars 19 forks source link

Logging array values #10

Open endorama opened 9 years ago

endorama commented 9 years ago

I've found a wrong behaviour when logging arrays.

I'm logging an object like this:

{ name: 'string',
  energy: 
   { isConsistent: true,
     lastUpdate: '2015-05-20T17:30:00.000Z', },
  hourly: 
   [ 1 value per hour since same day 00:00 ] }

Using the human formatter the object is printed this way:

[2015-05-20 18:24:39] DEBUG:  (/.../index.js:50)
  name: string
  energy: 
      {
          "isConsistent": true,
          "lastUpdate": "2015-05-20T17:30:00.000Z",
      }
  hourly: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

The problem seems to be human.js#L68 where you check for string [object Object] while the string coming from toString() is like [object Object],[object Object],....

Using util.inspect works fine, and is my current workaround ( I defined a custom formatter with only that line changed ). There is some specific reason why has not been used util.inspect? There is some other way in which I can resolve this issue ( apart from stringifing the content before loggin in)?

Thank you for this library and you support :)