Add download logs button for Plex logs

This commit is contained in:
JonnyWong16 2016-06-05 11:18:23 -07:00
parent 13ab4a9363
commit b28f0b65f0
2 changed files with 45 additions and 3 deletions

View file

@ -3282,6 +3282,30 @@ class WebInterface(object):
return serve_download(os.path.join(plexpy.CONFIG.LOG_DIR, log_file), name=log_file)
@cherrypy.expose
@requireAuth(member_of("admin"))
@addtoapi()
def download_plex_log(self, **kwargs):
""" Download the Plex log file. """
log_type = kwargs.get('log_type', 'server')
log_file = ""
if plexpy.CONFIG.PMS_LOGS_FOLDER:
if log_type == "server":
log_file = 'Plex Media Server.log'
log_file_path = os.path.join(plexpy.CONFIG.PMS_LOGS_FOLDER, log_file)
elif log_type == "scanner":
log_file = 'Plex Media Scanner.log'
log_file_path = os.path.join(plexpy.CONFIG.PMS_LOGS_FOLDER, log_file)
else:
return "Plex log folder not set in the settings."
if log_file and os.path.isfile(log_file_path):
return serve_download(log_file_path, name=log_file)
else:
return "Plex %s log file not found." % log_type
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))