wip
This commit is contained in:
parent
a5f5d86897
commit
38cbcffd7b
|
@ -101,10 +101,18 @@ func (f *FileSource) SupportedModes() []string {
|
||||||
|
|
||||||
//OneShotAcquisition reads a set of file and returns when done
|
//OneShotAcquisition reads a set of file and returns when done
|
||||||
func (f *FileSource) OneShotAcquisition(out chan types.Event, t *tomb.Tomb) error {
|
func (f *FileSource) OneShotAcquisition(out chan types.Event, t *tomb.Tomb) error {
|
||||||
log.Infof("Starting oneshot acquisition on %d files", len(f.files))
|
f.logger.Infof("Starting oneshot acquisition on %d files", len(f.files))
|
||||||
for _, filename := range f.files {
|
for _, filename := range f.files {
|
||||||
log.Infof("reading %s at once", filename)
|
fi, err := os.Stat(filename)
|
||||||
err := f.readFile(filename, out, t)
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not stat file %s : %w", filename, err)
|
||||||
|
}
|
||||||
|
if fi.IsDir() {
|
||||||
|
f.logger.Warnf("%s is a directory, ignoring it.", filename)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
f.logger.Infof("reading %s at once", filename)
|
||||||
|
err = f.readFile(filename, out, t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -251,8 +259,8 @@ func (f *FileSource) readFile(filename string, out chan types.Event, t *tomb.Tom
|
||||||
var scanner *bufio.Scanner
|
var scanner *bufio.Scanner
|
||||||
|
|
||||||
fd, err := os.Open(filename)
|
fd, err := os.Open(filename)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.logger.Errorf("Failed opening file: %s", err)
|
|
||||||
return errors.Wrapf(err, "failed opening %s", filename)
|
return errors.Wrapf(err, "failed opening %s", filename)
|
||||||
}
|
}
|
||||||
defer fd.Close()
|
defer fd.Close()
|
||||||
|
|
Loading…
Reference in a new issue