I'm having trouble logging meaningful error messages to my function logs, what I'm trying to achieve is have errors appear with the 'error' log level as bellow:
Instead, what I'm getting is this:
I'm using the following function to test this out:
exports.testError = functions.https.onRequest(async (request, response) =>
{
console.log('Hi');
//According to google this won't be logged as error
console.error('Error');
//But these will
console.error(new Error('error'));
console.error('Error', new Error('error'));
return response.status(500).send('Test is finished.');
})
The first image is of a random error and its purpose is to show what I want to achieve, which is: have erros be logged as errors.
The second image is the result of my tests, it shows that even when I'm following instructions from google(Reporting Errors) it is not working as intended.
Well I figured it out: I was using node 12, I changed it to node 10 and it now logs the errors as expected.