Using a spreadsheet as a logger


In Setting up your Apps Script Environment for Dogger I showed how to set up DriverScratch as a database to receive logging information from Multi user apps script logger. Since we are using Database abstraction with google apps script changing the backend to something else is simply changing a few parameters. 

As a reminder, here is the architecture.


 


 


yourDoggerServer

I'm going to copy the library I made for Setting up your Apps Script Environment for Dogger and 

Setting up the database handler

Copy  the yourDoggerServer script and replace the driver and tweak the profile credentials, using a spreadsheet ID and sheetname of your own.

var doggerProfile = {
  driver:cDriverSheet , 
  options : {
    siloid:'doggerlogger',
    dbid:'1yTQFdN_O2nFb9obm7AHCTmPKpf5cwAd78uNQJiCcjPk'
  }
};

Change the library reference in your script from cDriverScratch to cDriverSheet (you'll find information on all known public libraries below) - and you are good to go.

https://script.google.com/macros/s/AKfycbwZ2Hht93wTNzvRmYINYF7obaOHciBXWcP_wAiEtyGq70_x3cI/exec

Here's a couple of small tests to try.

function show() {
  var dogger = getDogger( false);
  Logger.log(dogger.getHandler().count());
}

function test() {
    var dogger = getDogger( false);
    dogger.log('h1');
    dogger.log('h2');
    dogger.log({some:'thing',someother:'otherthing'});
 
    var thread = getDogger( false,'somethread');
    thread.log('a thread');
    thread.log({some:'other',someother:'thing',thread:'somethread'});
    
 Logger.log(dogger.getHandler().count());
}

Now if you head over to your spreadsheet, you should find this


Creating a webapp

Just because you are using a spreadsheet, doesn't mean you can't also use the inspector. Just publish your new app and change the settings in the demo that's running at the bottom of this page (remember to match the parameters and IDS to your published app and spreadsheet credentials and set it out of demo mode)



You should see this


Demo


Go to settings below and adapt as above. 

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

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.

Comments