def log(self, *args, **kwargs): """ This function provides a useful framework for generating optional debugging output that can be displayed at an arbitrary level of indentation. """ if not self._dbg and not "enable" in kwargs.keys(): return if self._dbg and len(args) and not self._suspend: # (emulate print functionality; handle unicode as best as possible:) strs = [] for arg in args: try: strs.append(str(arg)) except: strs.append(repr(arg)) output = " ".join(strs) if self.name: output = self.name + ": " + output output = " " * 3 * self._indent + output if self._wxLog: from wxPython.wx import wxLogMessage # (if not already imported) wxLogMessage(output) else: self._outstream.write(output + "\n") self._outstream.flush() # else do nothing # post process args: for kwarg, value in kwargs.items(): if kwarg == "indent": self.SetIndent(value) elif kwarg == "enable": self.SetEnabled(value) elif kwarg == "suspend": self.SetSuspend(value) elif kwarg == "wxlog": self.SetWxLog(value) elif kwarg == "stream": self.SetStream(value)
def log(self, *args, **kwargs): """ This function provides a useful framework for generating optional debugging output that can be displayed at an arbitrary level of indentation. """ if not self._dbg and not 'enable' in kwargs.keys(): return if self._dbg and len(args) and not self._suspend: # (emulate print functionality; handle unicode as best as possible:) strs = [] for arg in args: try: strs.append(str(arg)) except: strs.append(repr(arg)) output = ' '.join(strs) if self.name: output = self.name+': ' + output output = ' ' * 3 * self._indent + output if self._wxLog: from wxPython.wx import wxLogMessage # (if not already imported) wxLogMessage(output) else: self._outstream.write(output + '\n') self._outstream.flush() # else do nothing # post process args: for kwarg, value in kwargs.items(): if kwarg == 'indent': self.SetIndent(value) elif kwarg == 'enable': self.SetEnabled(value) elif kwarg == 'suspend': self.SetSuspend(value) elif kwarg == 'wxlog': self.SetWxLog(value) elif kwarg == 'stream': self.SetStream(value)
def write(self, s): wxLogMessage(s)