Better logging for the syncing agent

Change-Id: If3c95919113360344fdec538240ee151395b5bee
diff --git a/gerrit-github-sync/gerrit-github-sync.sh b/gerrit-github-sync/gerrit-github-sync.sh
index 40aeedc..8dce71d 100644
--- a/gerrit-github-sync/gerrit-github-sync.sh
+++ b/gerrit-github-sync/gerrit-github-sync.sh
@@ -46,10 +46,14 @@
 
 git config --global http.cookiefile /opt/secrets/gerritcookies
 
-set -eux
+set -eu
 
 cd /tmp
 
+function log() {
+  echo "[$(date -u '+%Y-%m-%d %H:%M:%S')] $@"
+}
+
 function clone() {
   git clone $1 $3
   pushd $3
@@ -58,6 +62,7 @@
 }
 
 function sync_branch() {
+  log "sync_branch $@"
   local branch="$1"
   local bidirectional="$2"
   git checkout origin/${branch} -B ${branch} || {
@@ -65,6 +70,7 @@
     return 1
   }
 
+  log "Origin branch is $(git rev-parse origin/master), destination is $(git rev-parse destination/master)"
   if $bidirectional; then
     git rebase destination/${branch} || {
       echo "Failed to rebase ${branch} from destination, aborting sync..."
@@ -77,6 +83,7 @@
     }
   fi
 
+  log "New head for destination is $(git rev-parse HEAD)"
   git push destination ${branch} || {
     echo "Failed to push to destination..."
     return 1
@@ -84,6 +91,7 @@
 }
 
 function sync() {
+  log "sync $@"
   local bidirectional="$4"
   pushd $3
   shift 4