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 に答える