Logging custom functions using stackdriver in google apps script
Recently, console logging became available for Google Apps Script projects. It used to
be impossible to use the Log service that comes with the GAS runtime, but now all
you need to do is throw
an exception. Exceptions get logged in stackdriver logging and
when enabled, unhandled exceptions will not stop your script execution. This adds up
to nearly 0 lag if you are using this feature (?) by purposely throwing exceptions, and you
can get creative with your error message to avoid having to expand stackdriver's log messages
(which are pretty comprehensive stacktraces!)