litixsoft / log4js-node-mongodb

A log4js-node log appender to write logs into MongoDB
MIT License
39 stars 23 forks source link

Trivial change to safely check for a string log message. #1

Closed maxnachlinger closed 10 years ago

maxnachlinger commented 10 years ago

typeof loggingEvent.data[0] === 'string' will fail if loggingEvent.data[0] was created via new String("some logging here"); My evidence:

node
> var s = "this is a string"; typeof s;
'string'
> var s = new String('this is a string'); typeof s;
'object'
> var s = "this is a string"; Object.prototype.toString.call(s) === '[object String]';
true
> var s = new String('this is a string'); Object.prototype.toString.call(s) === '[object String]';
true

Yes, this is truly a trivial change :) At any rate, here's my fix.

4kochi commented 10 years ago

Thanks for the fix.