ditojs / dito

Dito.js is a declarative and modern web framework with a focus on API driven development, based on Objection.js, Koa.js and Vue.js – Developed at Lineto by Jürg Lehni and made available by Lineto in 2018 under the MIT license
https://lineto.com
MIT License
82 stars 8 forks source link

Add pino as app logger #43

Closed ptoussai closed 3 years ago

ptoussai commented 3 years ago

Make it available through app and ctx.

ptoussai commented 3 years ago

Pretty print is enabled by default, and the output will be similar to how it currently is.

Example:

[15:19:05.269] INFO  (requests): <-- GET /api/me
[15:19:05.282] INFO  (requests): --> GET /api/me 200 13ms 

The configuration of the logger will be done in the config like:

  logger: {
    prettyPrint: true,
    level: 'info'
  }

I decided to no put that under config.log to not cause confusion.

Everything configured by config.log still uses the console. I think it's OK since it's usually meant for debugging. In the future, this could use Pino and be configured by setting the level instead.

lehni commented 3 years ago

Thanks @ptoussai!