Move track logging to a separate class

This separates the track logging code from the main logic of the
UserActions. Checking if logging is on at every logging call is also
faster than just not opening the ofstream.