Reputation: 571
I'm using simple runtime logging a lot in my Node.JS Cloud Functions
console.log('I am a log entry!');
Is console.log in Cloud Functions asynchronous in its nature?
Upvotes: 1
Views: 237
Reputation: 4069
As @slebetman stated, In the original implementation of node.js it was asynchronous. However, console.log()
was made synchronous some time in version 4 (2015). The reason for it was to avoid losing logs when a node process crashes. Making it synchronous ensures that all the text of the log gets printed before the process dies.
Note: However, 3rd party logging libraries like Winston or syslog may still be asynchronous. Some may be configured to be sync or async. The built-in console.log()
is synchronous.
Upvotes: 3