indexzero/winston-syslog — pull request #18 by justcfx2u (2013-10-23 15:28:20+00:00)
Title: Fix unnecessary JSONification of 'message' if meta not supplied.

The test of `meta ? ... : ...` seems insufficient to test whether `meta` was actually passed into the logging function with meaningful data. Since `meta` appears to always be passed (but as an empty object `{}` if it was not specified), this test was always true.

This patch tests for an empty object slightly more effectively than `meta ? ... : ...` which allows the ternary operation to succeed or fail based on the intent of the code.

Without patch:

logger.info('Hello!');
logger.info('Hello!', {with: 'metadata this time'});

Oct 23 11:14:08 pi-iad03-01 localhost minion.js[10702]: {"message":"Hello!"}
Oct 23 11:14:08 pi-iad03-01 localhost minion.js[10702]: {"with":"metadata this time","message":"Hello!"}

With patch:

logger.info('Hello!');
logger.info('Hello!', {with: 'metadata this time'});

Oct 23 11:12:38 my_hostname localhost minion.js[10699]: Hello!
Oct 23 11:12:38 my_hostname localhost minion.js[10699]: {"with":"metadata this time","message":"Hello!"}