Multi user apps script logger


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, 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.



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 Parse.com), you can look at those directly, or plug in the inspector as you prefer.
 


 


Inspector details

For help and more information join our community,  follow the blog,  follow me on twitter, or follow me on g+

You want to learn Google Apps Script?

Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, All formats are available from O'ReillyAmazon and all good bookshops. You can also read a preview on O'Reilly

If you prefer Video style learning I also have two courses available. also published by O'Reilly.
Google Apps Script for Developers and Google Apps Script for Beginners.