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

Polymer inspector

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, Database abstraction with google apps script.
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 forum and let me know if you care.
Here’s what the inspector looks like.

How it works

  • A library – cDogger – is provided to create and write log information.
  • You create your own library from a template, which references cDogger, and contains your preferences for database backend and secret credentials. Instead of Logger.log() , you use Dogger.log() via this library.
  • Optionally, you publish this library as a webapp (again from a template). This allows non-apps script clients (such as the log inspector) to be able to read the log files.
  •  If you choose to use some  database (such as a spreadsheet or, you can look at those directly, or plug in the inspector as you prefer.

For help and more information join our community,  follow the blog,  follow me on Twitter