GCP Console: console.log() spans multiple rows

Viewed 408

I am migrating my Cloud Functions to nodejs10 from nodejs8 and all my console.log() now spans multiple rows on GCP console instead of just 1 row.

In Nodejs8, this is how my console.log looks like: enter image description here

Now in Nodejs10, it looks like this: enter image description here

My code as such:

function someFunction() {
    return axios.get(url, config)
    .then((response) => response.data)
    .catch((err) => {
        console.log('Retrying..', err)
    })
}

I have attempted console.info() as per the docs, but it still spans multiple rows. How do I compact this one console.log into one single entry/row on GCP console?

1 Answers

What you are referring to is not product-related. It's a fairly common problem due to how each line is logged as a separate event. For example, if you do a quick search on the internet for "multi-line logging problem", you may be able to find a third-party solution. However, most of these solutions involve post-processing of data logs after an export of the logs are done. I don't think you will be able to alter the way the logs are displayed in the first place. If you think the export is a viable workflow, the GCP documentation for exporting is here.

Related