diff --git a/python/plugins/processing/core/ProcessingLog.py b/python/plugins/processing/core/ProcessingLog.py index 0b4e4c4d5da..373ea64550a 100644 --- a/python/plugins/processing/core/ProcessingLog.py +++ b/python/plugins/processing/core/ProcessingLog.py @@ -32,6 +32,8 @@ from processing.tools.system import userFolder from processing.core.ProcessingConfig import ProcessingConfig from qgis.PyQt.QtCore import QCoreApplication +LOG_SEPARATOR = '|~|' + class ProcessingLog: @@ -55,8 +57,8 @@ class ProcessingLog: # added. To avoid it stopping the normal functioning of the # algorithm, we catch all errors, assuming that is better # to miss some log info than breaking the algorithm. - line = 'ALGORITHM|' + datetime.datetime.now().strftime( - ProcessingLog.DATE_FORMAT) + '|' \ + line = 'ALGORITHM' + LOG_SEPARATOR + datetime.datetime.now().strftime( + ProcessingLog.DATE_FORMAT) + LOG_SEPARATOR \ + msg + '\n' with codecs.open(ProcessingLog.logFilename(), 'a', encoding='utf-8') as logfile: @@ -80,10 +82,14 @@ class ProcessingLog: lines = f.readlines() for line in lines: line = line.strip('\n').strip() - tokens = line.split('|') + tokens = line.split(LOG_SEPARATOR) + if len(tokens) <= 1: + # try old format log separator + tokens = line.split('|') + text = '' for i in range(2, len(tokens)): - text += tokens[i] + '|' + text += tokens[i] + LOG_SEPARATOR if line.startswith('ALGORITHM'): entries.append(LogEntry(tokens[1], tokens[2])) @@ -108,7 +114,7 @@ class ProcessingLog: entries = ProcessingLog.getLogEntries() with codecs.open(fileName, 'w', encoding='utf-8') as f: for entry in entries: - f.write('ALGORITHM|%s|%s\n' % (entry.date, entry.text)) + f.write('ALGORITHM{}{}{}{}\n'.format(LOG_SEPARATOR, entry.date, LOG_SEPARATORentry.text)) @staticmethod def tr(string, context=''):