Initial refactor of file logging