functions.netlify.com icon indicating copy to clipboard operation
functions.netlify.com copied to clipboard

Using console.log in Netlify JS functions

Open kaushalmodi opened this issue 5 years ago • 4 comments

Hello,

I am not a JS coder, but I know Nim.

So I am trying to use the Nim JS FFI feature to export Nim code to JS and use those as Netlify functions.

My experiments:

As I don't know JS, I think that the console.log functions should help me better debug the Nim -> JS generated functions. But I cannot make them work (I was hoping that console.log outputs would show up in the Console when added to the Netlify functions too).

Does console.log work? If yes, can you possible show an example of where you would place it in this Nim generated hello.js?

kaushalmodi avatar Oct 26 '18 20:10 kaushalmodi

I have tried putting 4 console.logs here [JS source], but they don't show up in the browser console.

kaushalmodi avatar Oct 26 '18 20:10 kaushalmodi

OK, so from https://www.netlify.com/docs/functions/#managing-your-functions, I learn that I can see the console.log() outputs at https://app.netlify.com/sites/SITENAME/functions/FUNCNAME.

  • But only the console.log invocations inside the exports.handler (these) are showing up there.
  • These which are outside of that exports.handler are not showing up in https://app.netlify.com/sites/SITENAME/functions/FUNCNAME or in the browser Console. Is that expected?

Can you please update the Netlify docs page I linked above with more details?

Thanks!

kaushalmodi avatar Oct 26 '18 21:10 kaushalmodi

Sorry to bump this old thread but has there been any updates here? Logging is very important.

bpinto avatar Nov 27 '19 12:11 bpinto

This is still and issue. I can trigger a webhook to fire and receive a 200 response from the function but the log output in the Netlify dashboard is empty despite the presence of a few console.log() which work as intended using netlify dev.

james-innes avatar Sep 22 '20 11:09 james-innes