Complete logging example, some restructuring