Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Oct 9, 2023
1 parent 948f3cf commit 01e4176
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions internal/prefixcollector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func (epc *ExcludedPrefixCollector) Serve(ctx context.Context) {
for {
select {
case <-epc.notifyChan:

// Можно тут прочитать весь канал

epc.updateExcludedPrefixes(ctx)
case <-ctx.Done():
return
Expand Down
3 changes: 2 additions & 1 deletion internal/prefixcollector/collector_file_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ func (eps *ExcludedPrefixesSuite) watchFile(ctx context.Context, prefixesFilePat
close(errorCh)
return
}

if event.Op&fsnotify.Write == fsnotify.Write {
modifyCount++
log.FromContext(ctx).Infof("File is modified. Operation: %s", event.Op.String())
log.FromContext(ctx).Infof("File is modified. Event: %v. Operation: %s.", event.String(), event.Op.String())
if modifyCount == maxModifyCount {
close(errorCh)
return
Expand Down
8 changes: 3 additions & 5 deletions internal/prefixcollector/prefix_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ func fileWriter(filePath string) writePrefixesFunc {
return
}

if ctx.Err() == nil {
err = os.WriteFile(filePath, data, outputFilePermissions)
if err != nil {
log.FromContext(ctx).Fatalf("Unable to write into file: %v", err.Error())
}
err = os.WriteFile(filePath, data, outputFilePermissions)
if err != nil {
log.FromContext(ctx).Fatalf("Unable to write into file: %v", err.Error())
}
}
}
Expand Down

0 comments on commit 01e4176

Please sign in to comment.