Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress watchmedo on_any_event log messages #594

Closed
garyns opened this issue Nov 12, 2019 · 3 comments · Fixed by #889
Closed

Suppress watchmedo on_any_event log messages #594

garyns opened this issue Nov 12, 2019 · 3 comments · Fixed by #889

Comments

@garyns
Copy link

garyns commented Nov 12, 2019

When using watchmedo auto-restart how can I suppress all the event messages logged to the console? It's noise I do not want to see.

Thanks.

Eg:

$ watchmedo auto-restart test.sh
on_any_event(self=<watchdog.tricks.AutoRestartTrick object at 0xb634ab30>, event=<FileCreatedEvent: src_path='./4913'>)
on_any_event(self=<watchdog.tricks.AutoRestartTrick object at 0xb634ab30>, event=<DirModifiedEvent: src_path='.'>)
on_any_event(self=<watchdog.tricks.AutoRestartTrick object at 0xb634ab30>, event=<FileModifiedEvent: src_path='./4913'>)
on_any_event(self=<watchdog.tricks.AutoRestartTrick object at 0xb634ab30>, event=<FileDeletedEvent: src_path='./4913'>)
on_any_event(self=<watchdog.tricks.AutoRestartTrick object at 0xb634ab30>, event=<DirModifiedEvent: src_path='.'>)
@danilobellini
Copy link
Collaborator

As of today, there's no way, because of the watchdog.utils.echo.echo decorator applied on the watchdog.tricks.AutoRestartTrick.on_any_event method. This decorator writes unconditionally to stdout. A path to solve this issue would be:

  • Add -v/-vv verbosity mode (show INFO/DEBUG) and -q/--quiet (hide WARNING) options to all watchmedo commands;
  • Let all "echo" functions in utils accept a logger from logging instead of a file object;
  • Make all watchmedo commands use the "echo" functions with a logger instead of stdout. The new logger should write to stderr instead of stdout.

I wonder how many people use the watchdog.utils.echo module, it's mostly part of the watchmedo, but that proposed change can be done without breaking the current behavior of those functions.

@and3rson
Copy link

Is this still planned? I've been using watchmedo for a long time, but those log messages are really spamming entire output, making it hard to visually find any relevant logs.

@BoboTiG
Copy link
Collaborator

BoboTiG commented Oct 21, 2020

Nothing is planed, but PRs are very welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants