mperdeck/jsnlog.js

stringifyLogObject() : msg set to null cause exception

cdupetit opened this issue · 3 comments

Hello,
In the function stringifyLogObject() when actualLogObject has a type of object, if actualLogObject is not an instance of RegExp, String, Number or Boolean, the function return a new StringifiedLogObject with the first param set to null.
This params correspond to the msg member of the class and in some case it cause exception break.

For example for winston.transport.email in the function log :

 var msgOptions = {
    from: this.from,
    to: this.to,
    subject: mustache.render(this.subject, {level: level, msg: msg.split('\n')[0]}),
    text: body,
  }

msg.split() cause an exception.
My question : "Is this this normal for the msg param to be set to null ?"
Best Regards.
Cyril

Hello @mperdeck
Did you plan any fix on this issue ?
Thanks.

Sorry for the late reply.

I've changed the code so for objects it will set msg to "" instead of null. This will go out with the next release.

So far, I have been unable to find a specification of the interface of a Winston transport (apart from the existence of the level, msg, meta and callback fields).