@keeprunning(SCAN_FPATTERNS_INTERVAL, on_error=util.log_exception)<EOL><INDENT>def _scan_fpatterns(self, state):<DEDENT>
for f in self.fpaths:<EOL><INDENT>fpattern, formatter =(a.split('<STR_LIT:=>')[<NUM_LIT:1>] for a in f.split('<STR_LIT::>', <NUM_LIT:1>))<EOL>self.log.debug('<STR_LIT>', fpattern=fpattern, formatter=formatter)<EOL>fpaths = glob.glob(fpattern)<EOL>fpaths = list(set(fpaths) - set(state.files_tracked))<EOL>for fpath in fpaths:<EOL><INDENT>try:<EOL><INDENT>formatter_fn = self.formatters.get(formatter,<EOL>load_formatter_fn(formatter))<EOL>self.log.info('<STR_LIT>', fn=formatter)<EOL>self.formatters[formatter] = formatter_fn<EOL><DEDENT>except (SystemExit, KeyboardInterrupt): raise<EOL>except (ImportError, AttributeError):<EOL><INDENT>self.log.exception('<STR_LIT>', fn=formatter)<EOL>sys.exit(-<NUM_LIT:1>)<EOL><DEDENT>self.log.info('<STR_LIT>', log_file=fpath)<EOL>log_f = dict(fpath=fpath, fpattern=fpattern,<EOL>formatter=formatter, formatter_fn=formatter_fn)<EOL>log_key = (fpath, fpattern, formatter)<EOL>if log_key not in self.log_reader_threads:<EOL><INDENT>self.log.info('<STR_LIT>', log_key=log_key)<EOL>log_reader_thread = util.start_daemon_thread(self.collect_log_lines, (log_f,))<EOL>self.log_reader_threads[log_key] = log_reader_thread<EOL><DEDENT>state.files_tracked.append(fpath)<EOL><DEDENT><DEDENT>time.sleep(self.SCAN_FPATTERNS_INTERVAL)<EOL>
For a list of given fpatterns, this starts a thread
collecting log lines from file

>>> os.path.isfile = lambda path: path == '/path/to/log_file.log'
>>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30)

>>> print(lc.fpaths)
file=/path/to/log_file.log:formatter=logagg.formatters.basescript

>>> print('formatters loaded:', lc.formatters)
{}
>>> print('log file reader threads started:', lc.log_reader_threads)
{}
>>> state = AttrDict(files_tracked=list())
>>> print('files bieng tracked:', state.files_tracked)
[]


>>> if not state.files_tracked:
>>>     lc._scan_fpatterns(state)
>>>     print('formatters loaded:', lc.formatters)
>>>     print('log file reader threads started:', lc.log_reader_threads)
>>>     print('files bieng tracked:', state.files_tracked)