Open
Description
Version: 2.9.0
We don't always want to add context to an error - sometimes console.error(new Error('bang'))
is fine. If you do that, however, it still tries to add the context to the message
field, e.g.
const { LoggerAdaptToConsole } = require('console-log-json');
LoggerAdaptToConsole();
console.error(new Error('bang'));
outputs
{"level":"error","message":" - bang", ...}
With context, it works fine, e.g.
const { LoggerAdaptToConsole } = require('console-log-json');
LoggerAdaptToConsole();
console.error(new Error('bang'), 'context');
outputs
{"level":"error","message":"context - bang", ...}
If no context is provided, it should leave the message
field alone, e.g. {"level":"error","message":"bang", ...}
I believe this should remove that leading -
, but there are actually two spaces before the hyphen, so it wouldn't catch it. There are always two spaces before the hyphen, even when there is context.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels