def _init_capturelog(self): """ Configure the capture log for this process. This log is used to temporarily capture output when special output is detected. Sets self.capturelog if capturing is enabled. """ capture_maxbytes = getattr(self.process.config, '%s_capture_maxbytes' % self.channel) if capture_maxbytes: self.capturelog = self.process.config.options.getLogger() loggers.handle_boundIO( self.capturelog, fmt='%(message)s', maxbytes=capture_maxbytes, )
def __init__(self, process, event_type, fd): """ Initialize the dispatcher. `event_type` should be one of ProcessLogStdoutEvent or ProcessLogStderrEvent """ self.process = process self.event_type = event_type self.fd = fd self.channel = channel = self.event_type.channel self._setup_logging(process.config, channel) capture_maxbytes = getattr(process.config, '%s_capture_maxbytes' % channel) if capture_maxbytes: self.capturelog = loggers.handle_boundIO( self.process.config.options.getLogger(), fmt='%(message)s', maxbytes=capture_maxbytes, ) self.childlog = self.mainlog # all code below is purely for minor speedups begintoken = self.event_type.BEGIN_TOKEN endtoken = self.event_type.END_TOKEN self.begintoken_data = (begintoken, len(begintoken)) self.endtoken_data = (endtoken, len(endtoken)) self.mainlog_level = loggers.LevelsByName.DEBG config = self.process.config self.log_to_mainlog = config.options.loglevel <= self.mainlog_level self.stdout_events_enabled = config.stdout_events_enabled self.stderr_events_enabled = config.stderr_events_enabled