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

How to turn off logging? #50

Closed
fariazz opened this issue May 20, 2013 · 6 comments
Closed

How to turn off logging? #50

fariazz opened this issue May 20, 2013 · 6 comments

Comments

@fariazz
Copy link

fariazz commented May 20, 2013

When an event is triggered I get console logs like this:

<Event dir=False mask=0x2 maskname=IN_MODIFY name='' path=myfile.csv pathname=/home/me/myfile.csv wd=1 >

How do I turn off this logging behavior?

@seb-m
Copy link
Owner

seb-m commented May 20, 2013

Take a look at pyinotify.log()and to the class PrintAllEvents.

@seb-m seb-m closed this as completed May 20, 2013
@fariazz
Copy link
Author

fariazz commented May 20, 2013

not sure how to switch it off. Where do I have to define this class? My code is:

wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm)
wm.add_watch(self.price_file, pyinotify.IN_CLOSE_WRITE)
notifier.loop(callback=self.handler)

self.handler is just a dummy method that prints "file changed"

@seb-m
Copy link
Owner

seb-m commented May 20, 2013

callbackis not intended for this use, you should inspire yourself from this trivial example tutorial_notifier.py with in particular the class EventHandler.

@fariazz
Copy link
Author

fariazz commented May 20, 2013

thanks, callback here is working fine as I need it. I tried doing it as the tutorial before but in that case I need to create an EventHandler class, whereas what I needed was just to call a method that belongs to the current class object where all the code is located.

anyway that is working well as I implemented it. Just got stuck with the logging, but it's ok if there is no simple way to turn it off.

the code has been of great help to my project to thanks a lot for building it!

@seb-m
Copy link
Owner

seb-m commented May 20, 2013

Ok, do as you want but these events are printed because it is a default behavior resulting from the unusual fact there are no handler (such as EventHandler) defined in you code. Thus a 'by default' behavior of pyinotify makes it handle events by calling an instance of PrintAllEvents to print them. That's why I suggested you find a way to implement an event handler, even an empty one without any methods, just to override this default behavior.

@fariazz
Copy link
Author

fariazz commented May 20, 2013

got it! thanks I will implement an empty handler then.

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

No branches or pull requests

2 participants