Re-order stack.sh 3: logging and error traps

Part 3 of a series

Re-order the setup and check bits in the top portion of stack.sh to
have a logical flow with similar things done together.

No behaviour changes are intended aside from the order of execution.
Any such changes are bugs.

* Move logging and error configuration earlier to cover initial project setup.

Change-Id: Ib16bbe20f224b1cf5e86c7a2fda0d9472c108873
Merge "Re-order stack.sh 3: logging and error traps"