lib/winston-graylog2.js
/**
 * Preparing metadata for graylog
 * If we send a javascript `Error` object
 * to gray log we'll end up with the
 * `[object Object]` string.
 * To have our infos we need to get the stack out of the error.
 * Here we remap metadata to handle this kind of situation
 *
 * @param  {Object} meta
 * @param  {Object} staticMeta
 * @return {Object}
 */
Preparing metadata for graylog
If we send a javascript `Error` object
to gray log we'll end up with the
`[object Object]` string.
To have our infos we need to get the stack out of the error.
Here we remap metadata to handle this kind of situation


Preparing metadata for graylog If we send a javascript ` Error ` object to gray log we ' ll end up with the ` [ object Object ] ` string . To have our infos we need to get the stack out of the error . Here we remap metadata to handle this kind of situation
function prepareMeta(meta, staticMeta) {
  meta = meta || {};
  if (meta instanceof Error) {
    meta = {error: meta.stack};
  } else if (typeof meta === 'object') {
    meta = _.mapValues(meta, function(value) {
      if (value instanceof Error) {
        return value.stack;
      }
      return value;
    });
  }
  meta = _.merge(meta, staticMeta);
  return meta;
}
function prepareMeta ( meta , staticMeta ) { meta = meta || { } ; if ( meta instanceof Error ) { meta = { error : meta . stack } ; } else if ( typeof meta === 'object' ) { meta = _ . mapValues ( meta , function ( value ) { if ( value instanceof Error ) { return value . stack ; } return value ; } ) ; } meta = _ . merge ( meta , staticMeta ) ; return meta ; }
Preparing metadata for graylog
 If we send a javascript `Error` object
 to gray log we'll end up with the
 `[object Object]` string.
Preparing metadata for graylog If we send a javascript ` Error ` object to gray log we ' ll end up with the ` [ object Object ] ` string .