예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 def write(self, s):
     wxLogMessage(s)
예제 #4
0
 def write(self, s):
     wxLogMessage(s)