2
votes

I have two questions regarding logging with apps script:

1/ I have two .gs files (in the same project). One (F1) is calling the other (F2) via urlfetch (POST request). The Logger.log works just fine in F1, but doesn't in F2 (maybe it works too, but I just can't retrieve the logs). Do you know if it's normal or where can I find the logs of F2 ?
(If you're wondering, it's made this way so we can call the same function multiple times in parallel).

2/ My scripts are linked to a Google Cloud project and so I've seen we can retrieve some logs via Stackdriver. What logs ? Because those with Logger.log don't seem to be visible from there.

Thanks for your help

1
Think of the different .gs files in a project as ways of organizing your functions. The functions in each are available to each .gs file so if F2 has a function f2function(myVar) {//code} in F1 you can call it with f2function(sendVar); Logger.log is reported i the same log for both .gs files.Karl_S
The architecture is made this way to create different threads and so call the same function, multiple times, in parallelValentin Coudert
In your situation, I would log your data to a spreadsheet. I can't say for sure what the current situation is, but from personal experience, in the past, it seemed that in some situations, the logs from some functions did not print. You can create your own, simple log system, and just append data to a spreadsheet. I have a function name ll. function ll(a,b,c) {SpreadsheetApp.openById(id).getSheetByName('name').appendRow(a,b,c)} My function is not that simple, but I'm just showing the basics.Alan Wells

1 Answers

3
votes

Regarding your second question: Stackdriver Logging with Apps Script is a new feature, only accessible to G Suite Business customers that applied for early access. The following functions should work

console.log([data][,...])
console.info([data][,...])
console.warn([data][,...])
console.error([data][,...])
console.time([label])