question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2.4.0 eats Error objects when logging

See original GitHub issue

After upgrading from 2.3.0 to 2.4.0, winston stops logging errors when using:

logger.error("Message", new Error("hello"));

I am using this piece of code for formatter

function configuredFormatter(colors) {
    /**
     * @param {Object} options
     * @return {string}
     */
    return function formatter(options) {
        let {
            meta,
            level,
            label,
            message,
            timestamp
        } = options;

        let {
            from,
            stack, trace,
            message: objectMessage
        } = meta;

        delete meta.from;
        delete meta.message;
        delete meta.stack;
        delete meta.trace;

        let formattedMessage = new Message()
            .setColorizer(new Colorizer(colors))
            .setTime(timestamp)
            .setLabel(label)
            .setLevel(level)
            .setFrom(from)
            .setMessage(message || objectMessage)
            .toString();

        formattedMessage += utils.getStackTrace(stack || trace);
        formattedMessage += utils.metaToYAML(meta);

        return formattedMessage;
    };
}

on 2.4.0 there is no stack/trace etc. there is no sign of the error object in the arguments. the result is that the error is not printed to logs correctly.

downgrading to 2.3.0 fixes the problem.

upgrading to 3.0.0-rc1 + using winston.createLogger makes the app loop forever displaying the first log message which is really weird 😐

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ninja-commented, Jan 10, 2018

There are discussions on the exact same problem here…nothing was fixed since, sadly. https://github.com/winstonjs/winston/pull/977 https://github.com/winstonjs/winston/pull/1042 #1007

0reactions
denissabramovscommented, Aug 9, 2021

It seems there is the same problem in v3.3.3. It eats/swallows error.message if error is provided with a introduction string, like this: logger.error('ops', new Error('this will not be visible')); While this will work: logger.error(new Error('this will be visible'));

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Loggin not showing in the console - Stack Overflow
i am struggling with Spring Boot Loggin. I am not able to print log.info or log.error on ...
Read more >
Magento 2.4.3 : Type Error occurred when creating object ...
First : Try to rm -rf generated/ then bin/magento setup:di:compile to be sure your generated code is the good one. If the error...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
Bug :2 - "How do I attach an ebuild. ... Bug:468 - "Zope 2.4.0/2.5.0 both give error about Makefile.pre.in not having boot target"...
Read more >
HAProxy 2.4 Changelog
REGTESTS: ssl/log: test the log-forward with SSL - DOC: fix TOC in starter guide for subsection 3.3.8. Statistics - BUG/MEDIUM: captures: free() an...
Read more >
console.log() - Web APIs - MDN Web Docs
Please be warned that if you log objects in the latest versions of Chrome and Firefox what you get logged on the console...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found