pinojs / pino-abstract-transport

Write Pino transports easily
MIT License
34 stars 13 forks source link

Add an ability to set keys for `time` and `level` #39

Open paulish opened 2 years ago

paulish commented 2 years ago

Hello.

I have an issue with using @elastic/ecs-pino-format package together with pino-pretty which uses pino-abstract-transport internally.

The problem is that @elastic/ecs-pino-format use custom formatters which changes time field to @timestamp and level to log.level. As result pino-abstract-transport can not fulfill metadata object correctly because of this code:

    if (stream[metadata]) {
      stream.lastTime = value.time
      stream.lastLevel = value.level
      stream.lastObj = value
    }

Here the library takes hard-coded time and level fields and gives no options to override this behavior.

mcollina commented 2 years ago

Would you like to send a Pull Request to address this issue? Remember to add unit tests.