Write data to the log file, if active
(self, data, kind='input')
| 185 | self.log_write(line_mod) |
| 186 | |
| 187 | def log_write(self, data, kind='input'): |
| 188 | """Write data to the log file, if active""" |
| 189 | |
| 190 | #print 'data: %r' % data # dbg |
| 191 | if self.log_active and data: |
| 192 | write = self.logfile.write |
| 193 | if kind=='input': |
| 194 | if self.timestamp: |
| 195 | write(time.strftime('# %a, %d %b %Y %H:%M:%S\n', time.localtime())) |
| 196 | write(data) |
| 197 | elif kind=='output' and self.log_output: |
| 198 | odata = u'\n'.join([u'#[Out]# %s' % s |
| 199 | for s in data.splitlines()]) |
| 200 | write(u'%s\n' % odata) |
| 201 | self.logfile.flush() |
| 202 | |
| 203 | def logstop(self): |
| 204 | """Fully stop logging and close log file. |
no test coverage detected