def METHOD_NAME(self, target, *args):
    wx.CallAfter(target.AppendText, *args)
    # Text output reveals logging window.
    self.Show()
    with self.cacheLock:
        self.textCache += ' '.join(map(str, args))
        if '\n' in self.textCache:
            # Ended a line; send the text to the logs, minus any trailing
            # whitespace (since the logs add their own trailing newline.
            # We strip any unicode with filter to prevent a cascade of
            # ---Logging Error--- messages.
            if target is self.stdOut:
                cockpit.util.logger.log.debug(''.join(filter(lambda c: ord(c) < 128, self.textCache)))
            else:
                cockpit.util.logger.log.error(''.join(filter(lambda c: ord(c) < 128, self.textCache)))
            self.textCache = ''