benbria / bunyan-debug-stream

A stream for bunyan that writes log entries as human readable output.
MIT License
30 stars 9 forks source link

TypeError in utils.js #6

Closed YouriT closed 5 years ago

YouriT commented 8 years ago

Getting an error with this module on version 1.0.7 Here it is:

TypeError: undefined is not a function
    at ...node_modules/bunyan-debug-stream/lib/utils.js:31:25

The error references to the fact that in this file you do a date.get... but date is an ISOString and not an object.

Thanks for this great work!

jwalton commented 8 years ago

Sorry for not replying to this earlier - was on vacation when you raised it, and I missed it.

How are you getting an ISOString out of bunyan? What version of bunyan are you using? Easy enough to add a date = new Date(date) here if we need to, though.

veeramarni commented 7 years ago

I think by adding time variable will fix this issue.

  const bunyanDebugStream = require('bunyan-debug-stream');
  // stream: process.stdout,
  const stream = bunyanDebugStream({
    basepath: __dirname, // this should be the root folder of your project.
    forceColor: true,
  });
  streams = [{
    level: level || 'debug',
    type: 'stream',
    stream,
  }];
}
const logger = bunyan.createLogger({
  name: app,
  time: Date,
  streams
});
jaulz commented 5 years ago

Same issue here... using bunyan@^1.8.12

benbriadeploy commented 5 years ago

:tada: This issue has been resolved in version 1.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

noomorph commented 5 years ago

@benbriadeploy , I was just passing by... you rock 👍

jwalton commented 5 years ago

@benbriadeploy is a robot. :) But no problem.

jwalton commented 5 years ago

Also, I fixed this by making it so if entry.time is not a Date, then we just call toString() on it, which might be fantastically ugly (I have no idea how all of you are getting non-Dates into this field, so I don't know what to do here. :P) But, I also just added a feature in 2.0.0 that makes it so you can do something like:

new BunyanDebugStream({
    showDate: (time, entry) => return time.toISOString()
});

and then you can specify whatever kind of date format you want.