rethink and refactor of logging