File tree 2 files changed +25
-0
lines changed
python/plugins/processing
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,14 @@ def clearLog():
134
134
os .unlink (ProcessingLog .logFilename ())
135
135
ProcessingLog .startLogging ()
136
136
137
+ @staticmethod
138
+ def saveLog (fileName ):
139
+ entries = ProcessingLog .getLogEntries ()
140
+ with codecs .open (fileName , 'w' , encoding = 'utf-8' ) as f :
141
+ for k , v in entries .iteritems ():
142
+ for entry in v :
143
+ f .write ('%s|%s|%s\n ' % (k , entry .date , entry .text ))
144
+
137
145
138
146
class LogEntry :
139
147
Original file line number Diff line number Diff line change @@ -51,9 +51,14 @@ def __init__(self):
51
51
self .clearButton .setToolTip (self .tr ('Clear history and log' ))
52
52
self .buttonBox .addButton (self .clearButton , QDialogButtonBox .ActionRole )
53
53
54
+ self .saveButton = QPushButton (self .tr ('Save As...' ))
55
+ self .saveButton .setToolTip (self .tr ('Save history and log' ))
56
+ self .buttonBox .addButton (self .saveButton , QDialogButtonBox .ActionRole )
57
+
54
58
self .tree .doubleClicked .connect (self .executeAlgorithm )
55
59
self .tree .currentItemChanged .connect (self .changeText )
56
60
self .clearButton .clicked .connect (self .clearLog )
61
+ self .saveButton .clicked .connect (self .saveLog )
57
62
58
63
self .tree .setContextMenuPolicy (Qt .CustomContextMenu )
59
64
self .tree .customContextMenuRequested .connect (self .showPopupMenu )
@@ -70,6 +75,18 @@ def clearLog(self):
70
75
ProcessingLog .clearLog ()
71
76
self .fillTree ()
72
77
78
+ def saveLog (self ):
79
+ fileName = QFileDialog .getSaveFileName (self ,
80
+ self .tr ('Save file' ), '.' , 'Log files (*.log *.LOG)' )
81
+
82
+ if fileName == '' :
83
+ return
84
+
85
+ if not fileName .lower ().endswith ('.log' ):
86
+ fileName += '.log'
87
+
88
+ ProcessingLog .saveLog (fileName )
89
+
73
90
def fillTree (self ):
74
91
self .tree .clear ()
75
92
elements = ProcessingLog .getLogEntries ()
You can’t perform that action at this time.
0 commit comments