32
32
from processing .core .ProcessingConfig import ProcessingConfig
33
33
from qgis .PyQt .QtCore import QCoreApplication
34
34
35
+ LOG_SEPARATOR = '|~|'
36
+
35
37
36
38
class ProcessingLog :
37
39
@@ -55,8 +57,8 @@ def addToLog(msg):
55
57
# added. To avoid it stopping the normal functioning of the
56
58
# algorithm, we catch all errors, assuming that is better
57
59
# to miss some log info than breaking the algorithm.
58
- line = 'ALGORITHM|' + datetime .datetime .now ().strftime (
59
- ProcessingLog .DATE_FORMAT ) + '|' \
60
+ line = 'ALGORITHM' + LOG_SEPARATOR + datetime .datetime .now ().strftime (
61
+ ProcessingLog .DATE_FORMAT ) + LOG_SEPARATOR \
60
62
+ msg + '\n '
61
63
with codecs .open (ProcessingLog .logFilename (), 'a' ,
62
64
encoding = 'utf-8' ) as logfile :
@@ -80,10 +82,14 @@ def getLogEntries():
80
82
lines = f .readlines ()
81
83
for line in lines :
82
84
line = line .strip ('\n ' ).strip ()
83
- tokens = line .split ('|' )
85
+ tokens = line .split (LOG_SEPARATOR )
86
+ if len (tokens ) <= 1 :
87
+ # try old format log separator
88
+ tokens = line .split ('|' )
89
+
84
90
text = ''
85
91
for i in range (2 , len (tokens )):
86
- text += tokens [i ] + '|'
92
+ text += tokens [i ] + LOG_SEPARATOR
87
93
if line .startswith ('ALGORITHM' ):
88
94
entries .append (LogEntry (tokens [1 ], tokens [2 ]))
89
95
@@ -108,7 +114,7 @@ def saveLog(fileName):
108
114
entries = ProcessingLog .getLogEntries ()
109
115
with codecs .open (fileName , 'w' , encoding = 'utf-8' ) as f :
110
116
for entry in entries :
111
- f .write ('ALGORITHM|%s|%s \n ' % ( entry .date , entry .text ))
117
+ f .write ('ALGORITHM{}{}{}{} \n ' . format ( LOG_SEPARATOR , entry .date , LOG_SEPARATORentry .text ))
Collapse comment Comment on line R117
@nyalldawson , there's a comma missing after the second separator.
Code has comments. Press enter to view. 112
118
113
119
@staticmethod
114
120
def tr (string , context = '' ):
0 commit comments