示例#1
0
 def test_plog_stdout_event(self):
     options = DummyOptions()
     pconfig1 = DummyPConfig(options, 'process1', 'process1','/bin/process1')
     process1 = DummyProcess(pconfig1)
     from supervisor.events import ProcessLogStdoutEvent
     class DummyGroup:
         config = pconfig1
     process1.group = DummyGroup
     event = ProcessLogStdoutEvent(process1, 1, 'yo')
     headers, payload = self._deserialize(event.payload())
     self.assertEqual(headers['processname'], 'process1', headers)
     self.assertEqual(headers['groupname'], 'process1', headers)
     self.assertEqual(headers['pid'], '1', headers)
     self.assertEqual(payload, 'yo')
示例#2
0
 def test_ProcessLogStdoutEvent_attributes(self):
     from supervisor.events import ProcessLogStdoutEvent
     inst = ProcessLogStdoutEvent(1, 2, 3)
     self.assertEqual(inst.process, 1)
     self.assertEqual(inst.pid, 2)
     self.assertEqual(inst.data, 3)
     self.assertEqual(inst.channel, 'stdout')
示例#3
0
 def _log(self, data):
     if data:
         config = self.process.config
         if config.options.strip_ansi:
             data = stripEscapes(data)
         if self.childlog:
             self.childlog.info(data)
         if self.log_to_mainlog:
             if not isinstance(data, bytes):
                 text = data
             else:
                 try:
                     text = data.decode('utf-8')
                 except UnicodeDecodeError:
                     text = 'Undecodable: %r' % data
             msg = '%(name)r %(channel)s output:\n%(data)s'
             config.options.logger.log(self.mainlog_level,
                                       msg,
                                       name=config.name,
                                       channel=self.channel,
                                       data=text)
         if self.channel == 'stdout':
             if self.stdout_events_enabled:
                 notify(
                     ProcessLogStdoutEvent(self.process, self.process.pid,
                                           data))
         else:  # channel == stderr
             if self.stderr_events_enabled:
                 notify(
                     ProcessLogStderrEvent(self.process, self.process.pid,
                                           data))
示例#4
0
    def test_plog_stdout_event(self):
        options = DummyOptions()
        pconfig1 = DummyPConfig(options, 'process1', 'process1',
                                '/bin/process1')
        process1 = DummyProcess(pconfig1)
        from supervisor.events import ProcessLogStdoutEvent

        class DummyGroup:
            config = pconfig1

        process1.group = DummyGroup
        event = ProcessLogStdoutEvent(process1, 1, 'yo')
        headers, payload = self._deserialize(event.payload())
        self.assertEqual(headers['processname'], 'process1', headers)
        self.assertEqual(headers['groupname'], 'process1', headers)
        self.assertEqual(headers['pid'], '1', headers)
        self.assertEqual(payload, 'yo')
示例#5
0
 def _log(self, data):
     if data:
         config = self.process.config
         if config.options.strip_ansi:
             data = stripEscapes(data)
         if self.childlog:
             self.childlog.info(data)
         if self.log_to_mainlog:
             msg = '%(name)r %(channel)s output:\n%(data)s'
             config.options.logger.log(self.mainlog_level,
                                       msg,
                                       name=config.name,
                                       channel=self.channel,
                                       data=data)
         if self.channel == 'stdout':
             if self.stdout_events_enabled:
                 notify(
                     ProcessLogStdoutEvent(self.process, self.process.pid,
                                           data))
         else:  # channel == stderr
             if self.stderr_events_enabled:
                 notify(
                     ProcessLogStderrEvent(self.process, self.process.pid,
                                           data))