Meteor._debug() - how to save the stack trace


#1

I’ve created a function to catch the errors through Meteor._debug()

But I cannot save the value of stack variable. It is an object but there are no keys. JSON.stringify() also doesn’t work. When I do stack.toString() I can only get the first line of the stack trace. But it displays properly with console.log().

Any idea?

This is in the server

const originalMeteorDebug = Meteor._debug;
Meteor._debug = (message, stack) => {
    if (Meteor.isDevelopment) {
        console.log('===== message =====', message);
        console.log('===== stack =====', stack);
    }

    errorLogger.error(`Server Error: ${message}`, stack.toString());

    return originalMeteorDebug.apply(this, arguments);
};

#2

Here is the sample output in my admin panel


#3

@rjdavid check out the Kadira APM code for some of the inner secrets of getting this sort of info.

I used a bunch of those tricks in this package:

Would love to perhaps generalize all the error extraction tricks into a module that multiple packages could use.,…


#4

Thanks, @hexsprite. I’ll take a look.


#5

It worked. Thanks a lot.

We hate Meteor._debug (no single usage pattern)

:rofl: