def start_stream_to_path(self, path, flt): try: f = self.open_file(path) except IOError as v: raise exceptions.OptionsError(str(v)) self.stream = io.FilteredFlowWriter(f, flt) self.active_flows = set()
def start_stream_to_path(self, path, mode, flt): path = os.path.expanduser(path) try: f = open(path, mode) except IOError as v: raise exceptions.OptionsError(str(v)) self.stream = io.FilteredFlowWriter(f, flt) self.active_flows = set()
def maybe_rotate_to_new_file(self) -> None: path = datetime.today().strftime(_path(ctx.options.save_stream_file)) if self.current_path == path: return if self.stream: self.stream.fo.close() self.stream = None new_log_file = Path(path) new_log_file.parent.mkdir(parents=True, exist_ok=True) f = new_log_file.open(_mode(ctx.options.save_stream_file)) self.stream = io.FilteredFlowWriter(f, self.filt) self.current_path = path