0

我试图在执行以下操作时从继承自console.log()的类中省略这种数据:

asset: 
   PassThrough {
     filename: 'old_man',
     data: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 f0 00 f0 00 00 ff db 00 43 00 05 03 04 04 04 03 05 04 04 04 05 05 05 06 07 0c 08 07 07 07 07 0f 0b 0b 09 ... >,
     originalLocation: '/path/to/lib/image.jpg',
     contentType: [Getter/Setter],
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: null,
        ended: false,
        endEmitted: false,
        reading: false,

... ETC。

通常我会尝试类似的东西:

Object.defineProperty(self, 'PassThrough', {
    configurable: true,
    writable: true,
    enumerable: false
})

但是因为PassThrough它实际上不是对象的属性,所以它不起作用。如何隐藏流信息console.log()

(免责声明:我确实意识到这是设计使然,隐藏它可能是个坏主意;)

4

1 回答 1

0

console.log回到util.inspect. 如果您可以完全控制该类,您所要做的就是使用您的自定义逻辑实现检查。请参阅此处的文档:https ://nodejs.org/api/util.html#util_util_inspect_object_options

于 2016-02-09T19:00:46.273 回答