def log(lines, log_file=None):
        """Output log message."""
        err = False
        for line in lines:
            print(line)
            if log_file is not None:
                UtilClass.writelog(log_file, line, 'append')
            if 'BAD TERMINATION' in line.upper():
                err = True
                break
        if err:
            TauDEM.error('Error occurred when calling TauDEM function, please check!', log_file)