Skip to content

Commit

Permalink
add log
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed Oct 19, 2024
1 parent d04c62b commit dba2ee1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/provider/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (p *Provider) Start(ctx context.Context) error {
if err := p.watcher.Add(path); err != nil {
p.logger.Error(err, "failed to add watch", "path", path)
}
p.logger.Info("Watching file changed", "path", path)
ch := p.watcher.Events(path)
go func(c chan fsnotify.Event) {
for msg := range c {
Expand All @@ -82,6 +83,7 @@ func (p *Provider) Start(ctx context.Context) error {
case <-ctx.Done():
return nil
case event := <-aggCh:
p.logger.Info("file changed", "op", event.Op, "name", event.Name)
switch event.Op {
case fsnotify.Create:
dirs.Insert(event.Name)
Expand All @@ -90,7 +92,7 @@ func (p *Provider) Start(ctx context.Context) error {
dirs.Delete(event.Name)
files.Delete(event.Name)
default:
p.logger.Info("unexcepted event", "op", event.Op, "name", event.Name)
// do nothing
continue
}

Expand Down

0 comments on commit dba2ee1

Please sign in to comment.