captures log and lets you write the log only when you need it