I made the modification to the code that you suggested and it is now logging serial data when the button is pressed, thanks.
Should logging start and continue when the g-switch triggers or should logging only occur when the g-switch triggers?
Logging should start when the g-switch triggers (closes), log for the duration of the switch being closed and continue to log for a further 15 seconds after the switch opens again.