1

帮我摆脱困境

这是我的 console.log 的输出

{ [error: column "hello" does not exist]
name: 'error',
length: 119,
severity: 'ERROR',
code: '42703',
detail: undefined,
hint: undefined,
position: '1271',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
file: 'src\backend\parser\parse_relation.c',
line: '2655',enter code here
routine: 'errorMissingColumn' }

这是我的 logger.error 的输出

error: name=error, length=119, severity=ERROR, code=42703, detail=undefined, hi
nt=undefined, position=1271, internalPosition=undefined, internalQuery=undefined
, where=undefined, file=src\backend\parser\parse_relation.c, line=2655, routine=
errorMissingColumn

console.log is more understandable and clear ,but logger.error message is not clear understand
4

1 回答 1

0

我在这里找到了这个修复(我不是作者)

https://gist.github.com/johndgiese/59bd96360ce411042294

// Extend a winston by making it expand errors when passed in as the 
// second argument (the first argument is the log level).
function expandErrors(logger) {
  var oldLogFunc = logger.log;
  logger.log = function() {
    var args = Array.prototype.slice.call(arguments, 0);
    if (args.length >= 2 && args[1] instanceof Error) {
      args[1] = args[1].stack;
    }
    return oldLogFunc.apply(this, args);
  };
  return logger;
}

像魅力一样为我工作。

于 2015-01-27T13:21:44.137 回答