One of the interesting challenges, especially if you are using webapps, triggered tasks or running things in parallel is the persistence of log files. Logger.log only has one instance so it gets overwritten by the latest thing that ran, and it’s tied to the script instance, so you can’t get multiple scripts reporting into the same log file.
What is Dogger
Dogger is a Logger alternative that uses database abstraction to store log events. This means that you can use any of the supported backends. It was mainly this logging application that I created DriverScratch – a transient database that deletes itself if not accessed for a while – but you can use any backend you like – a spreadsheet would be good too.
Note that DriverScratch relies on the predictability of CacheService. Google warn that it’s not necessarily predictable, but I’ve found it works well for testing and logging. You can use a more permament back end if you want.
The Apps Script Environment
You’ll need a bit of set up of the apps script environment. Here’s how
- Setting up your Apps Script Environment for Dogger
- Using a spreadsheet as a logger
- Using cDogger library directly
- Logging multiple or detached processes to the same log
In addition to the logging capability, I also created a Polymer app which allows you to inspect the logger in real time (no need to wait for it to finish). Since Database abstraction with google apps script provides a locking mechanism, you can log multiple scripts to the same logger database. Since this was my first Polymer app, I’ve written up the experience here.
You can find this on Github
At the time of writing this, the inspector doesn’t work on IE. 15% of the visitors to this site use IE, and most of those are visiting the pages with Microsoft type content. I may find some time to try to figure out what’s up with IE. Contact me on the g+ community and let me know if you care.
Here’s what the inspector looks like.