adzejs/adze

How to use with Google Cloud?

Closed this issue · 5 comments

GCPs logs are rather odd. Using adze normally results in one log per line. So if I log an object, with 5 properties, I see 5 separate logs. I have tried to do a bit of research and it's something to do with stdout.

I tried using machineReadable, but it resulted in this error:

Converting circular structure to JSON
--> starting at object with constructor 'Socket'
| property 'parser' -> object with constructor 'HTTPParser'
--- property 'socket' closes the circle

Any ideas on how to configure adze to "work"? They have a few packages for compatability with loggers:

So, this seems to me to be occurring because you're logging an object that cannot be parsed into JSON using the standard JSON.stringify() function. It might help if you log a new object from the properties of the thing you want to log rather than logging the entire prototype.

For instance, if I have:

const socket = new WebSocket('https://example.com/socket');
adze().log("Socket", socket);

Instead I would:

const socket = new WebSocket('https://example.com/socket');
adze().log("Socket", { url: socket.url });

In other words, if you're trying to log object, be careful about how they are constructed.

@AJStacy this coupled with machineReadable, right? I would use the above suggestion in addition to passing the machineReadable flag?

Yes, machineReadable forces all logs to print as JSON strings. Let me know if that works for you.

I'll give it a try. Thanks!