mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
parent
9d251198a6
commit
647bd256b1
@ -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=''):
|
||||
|
Loading…
x
Reference in New Issue
Block a user