logparsing: more robust code