4

so I was trying to log objects and errors in the in the firebase emulator locally in my visual studio code terminal.

try {
    // send request
} catch (error) {
    logger.log('----');
    logger.error(error);
}

Problem is that the message is unreadable because the \nare not respected since it looks like the whole message is one string.

>  {"severity":"ERROR","message":"Error: Request failed with status code 405\n    at createError (/Users/jankalthofer/Documents/Git/type-mvp/functions/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/Users/jankalthofer/Documents/Git/type-mvp/functions/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/Users/jankalthofer/Documents/Git/type-mvp/functions/node_modules/axios/lib/adapters/http.js:236:11)\n    at IncomingMessage.emit (events.js:327:22)\n    at endReadableNT (_stream_readable.js:1225:12)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21) {\n  config: {\n    url: 'https://demo-cloud:demo-password@cloud.openshot.org/',\n    method: 'post',\n    data: '{\"name\":\"test\",\"width\":1080,\"height\":1920}',\n    headers: {\n      Accept: 'application/json, text/plain, */*',\n      'Content-Type': 'application/json;charset=utf-8',\n      'User-Agent': 'axios/0.19  ..

Here is an image of how the output looks in my terminal.

Is there another way to log object so they are correctly (json) formatted?

Thanks in advance!

Soni Sol
  • 2,367
  • 3
  • 12
  • 23
JKalthoefer
  • 121
  • 1
  • 9

0 Answers0