Matthew-Hsu / PiPass

Nintendo 3DS Homepass for the Raspberry Pi
149 stars 20 forks source link

Logging #9

Closed nagledb closed 9 years ago

nagledb commented 9 years ago

I think it'd be helpful if piPass logged its activity to a log file. Perhaps to /var/log/pipass? This log could include the kind of output messages we get currently on STDOUT when running it manually, plus could contain some additional messages for debugging if needed.

An example: I'm wondering if #4 might be occurring due to problems opening one of the files it reads/writes. If we wrapped the io.open blocks with a try block, we could catch any exception it raises, note what happened in the log, then gracefully quit. That would give us post mortem info that would help us determine if that was somehow the culprit.

I'd be happy to take a stab at doing this using Python's logging module if you want, but since it's such an intrusive change I wanted to discuss it first.

Matthew-Hsu commented 9 years ago

I agree, logging would be extremely helpful. I was able to find some time tonight and make some changes locally on my end that will hopefully fix that crashing bug. Depending on the results, I will push something either tomorrow night or the weekend.

You've contributed some pretty great features and I really appreciate it. A logging system that can be turned on or off would be great to have, but I am not sure if we need to implement something that exhaustive yet. Once that crashing bug is fixed, PiPass should be relatively solid.

PiPass is really a fun project for me to try some things out that I haven't really tried yet. Python logging seems interesting, so if it is something you would enjoy doing, feel free to give it a shot. I may eventually get around to it sometime, but don't feel compelled to do so.

Again, thanks for all your contributions so far and I really enjoy the features you've added!

nagledb commented 9 years ago

I'm not sure why this didn't occur to me sooner but there's a much easier solution for logging: just redirect STDOUT and STDERR to a log file when piPassCommand starts up piPass. Pair that with a conf file in /etc/logrotate.d to ensure it doesn't grow out of control and that should be more than sufficient.

It'd probably be pretty simple to implement, but given the issues/changes under discussion in #4 I'll hold off on it until we see what comes of that since it may change where/how piPass gets started.

Matthew-Hsu commented 9 years ago

I've pushed the changes on the master branch already. Issue #4 should be fixed now. piPassCommand has been removed. You can still get output manually from piPass, but I'm thinking of just outputting those regular messages to a file instead and just performing a cleanup where applicable.

Matthew-Hsu commented 9 years ago

I've implemented a logging system in PiPass using the Python logging module. It works quite well and it was pretty smooth to implement.

Since, the command console was semi-retired, I've brought it back in another form through PiPass Logging in the dashboard.