Changed function process_log() for simplification and improve maintainability.