I am starting to write my first channel plugin and it is partially working, and its been a real struggle up to this point. I’ve gotten a lot of good tips and ideas from looking at other plugins, but what I can’t see from them is how they debug their issues. Along the way I have been Loging to check my variables, but the log doesn’t seem consistent. There are 6 logs which all look like they have varied information. I don’t know which log is which, and even tailing some logs don’t seem to update.
plex@plex:~/Library/Application Support/Plex Media Server/Logs/PMS Plugin Logs$ ls -ahl com.plexapp.plugins.nowplaying*
-rw-r--r-- 1 plex plex 11K Aug 7 09:56 com.plexapp.plugins.nowplaying.log
-rw-r--r-- 1 plex plex 8.2K Aug 7 09:54 com.plexapp.plugins.nowplaying.log.1
-rw-r--r-- 1 plex plex 27K Aug 7 09:49 com.plexapp.plugins.nowplaying.log.2
-rw-r--r-- 1 plex plex 9.6K Aug 7 09:36 com.plexapp.plugins.nowplaying.log.3
-rw-r--r-- 1 plex plex 18K Aug 7 09:36 com.plexapp.plugins.nowplaying.log.4
-rw-r--r-- 1 plex plex 37K Aug 7 09:32 com.plexapp.plugins.nowplaying.log.5
I read in another forum post not to use the PlexWeb client when testing the plugins because of caching in the browser, but even testing on my iPad doesn’t seem very consistent. I guess my real issue for me is getting valuable info from the logs. Is the Plex server caching the plugins themselves? I have noticed that I make a few small changes and everything seems good then all of a sudden it stops working again and I try to debug it.
I have read the pdf “docs” and didn’t see anything valuable for me along the lines of debugging.
@chriscarpenter12 said:
Along the way I have been Loging to check my variables, but the log doesn’t seem consistent. There are 6 logs which all look like they have varied information. I don’t know which log is which, and even tailing some logs don’t seem to update.
.log.x is setup as rotating log files. .log is the current file being written. Log files start over when they reach a certain size/line limit or the channel/server starts/re-starts. If using tail in a Unix environment, I suggest using the -f flag to follow the last 10 lines dynamically.
I always tail -f the channel I’m developing, the com.plexapp.system.log and the Plex Media Server.log(if server logging enabled). If your channel uses Service Code, then its log info shows up within the com.plexapp.system.log as it is ran as system code independent of your channel/plugin environment. As for the main Plex Media Server log, it is only usefully if you have debug logging (or higher) enabled for your server. It will show you stream information, allowing you to know if the transcoder is behaving correctly and that your thumbs are being handled correctly. Please note that the Plex Media Server.log logs sensitive information that could allow other knowledgeable user to access your server and know your PMS IP/port as-well-as the email your Plex account is associated with, so be mindful when asking users for this log or providing it for others.
If using a try/except method you can use Log.Exception() to include the current stack trace.
As a side note, I normally write code outside of Plex’s Framework first as standalone code. That way I can quickly debug potential issues before migrating the code to Plex Framework functions. Also helps avoiding restarting server or channel for every small change due to simple programming errors.
@Twoure Thanks for your input. It is helpful. I didn’t mention but I was using tail -f --lines=100 to get a good look at the log. It just never seemed like it was ever updating. I will take a look at the other logs as well. I just assumed all the logging I would need that would be relevant would be in the plugin log.
I was able to hook up an IDE to my Channel code and run its parts from the test suites which I found really helpful in the development. My goal was to add automatic testing to my channels, but I can also debug the channel code using a Python debugger from IDE. The setup isn’t very convenient though and you’d have to write some tests for your channel. The good thing is that writing tests is generally a good practice and may prove useful in the future, for example, if something changes in the site and it breaks the channel, you may fix it really easily if your parsing functions are covered. If you wanted to give it a try, look up a thread named ‘Thoughts on channel development and automatic testing?’ in this subforum.