In Using cDogger library directly I showed how to use various backends for logging. One of the benefits of this approach is that you can get visibility into tasks that have been triggered, and consolidate their logfiles. You can of course use multiple back ends for this, and you can also use the cDogger library directly. In this example, I’m going to use a spreadsheet back end.
The steps are
  • Clear the log
  • Trigger a couple of simultaneous logging tasks
We’ll pretty much use the same code as in Using cDogger library directly, except that this time we’ll use threads to distinguish which task is actually logging, so start with the same libraries and code as you created for that.

Clear the log

// clear any existing data out
function sheetClear() {
  var dogger = getDogger(getSheetHandle());


Trigger a couple of tasks to run now

Trigger sheetA and sheetB. We’ll use the thread parameter to distinguish who is logging what.
// do some tests using thread A
function sheetA() {
  var dogger = getDogger(getSheetHandle(),"sheeta");
// do some tests using thread B
function sheetB() {
  var dogger = getDogger(getSheetHandle(),"sheetb");

And here’s a piece of the output on a sheet

You can see on the thread column the each task is logging its progress to the same sheet. DbAbstraction built in locking ensures that they can do this safely.

For more on this see Multi user apps script loggerPolymer and Database abstraction with google apps script

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