unjs / consola

🐨 Elegant Console Logger for Node.js and Browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consola default log object does not contain message property

Atinux opened this issue · comments

Reproduction link : https://repl.it/@gkatsans/Consola#index.js

The consola contrib repository doesnt seem to have a lot of activity in the issue tracker hence my posting here.

Reported in nuxt/nuxt#8712

Hi @gkatsanos. As Daniel mentioned in nuxt/nuxt#8712 (comment), it is up to reporters to concatenate args into message (if we do pre-formatting, handling objects like Error is impossible for a reporter that needs to for example format stacktrace)

Also docs is correct. Consola accepts message/additional for logObject that adds it to args array before passing to reporters.

You may use args.join(' ') for a simple formatter in custom repoter.

Also docs is correct. Consola accepts message/additional for logObject that adds it to args array before passing to reporters.
aha, now I get it. : https://repl.it/@gkatsans/Consola-2#index.js

message is a property that can be included in the object to be logged by consola, and anything within message will be passed in the args array.

If one wants a prop message to be in the output, they need a custom reporter that will fish out the message from the args array and place it in the object directly or elsewhere.

If one wants a prop message to be in the output, they need a custom reporter that will fish out the message from the args array and place it in the object directly or elsewhere.

Precisely :) Consola is mostly like a console middleware with built-in reporters. Reporters can connect it to a real logging infra like winston or sentry etc

If one wants a prop message to be in the output, they need a custom reporter that will fish out the message from the args array and place it in the object directly or elsewhere.

Precisely :) Consola is mostly like a middleware with built-in reporters. Reporters can connect it to a real logging infra like winston or sentry etc

In that case I guess I need winston, or the datadog logging library