Log errors via API
This commit is contained in:
1 parent
8e18c1e1cd
commit
66dfe75f73
4 files changed
+43
-2
No files matched your search
@@ -93,6 +93,12 @@ class Plugin(object):
|
|||||||
|
|
||||||
socket.setdefaulttimeout(timeout)
|
socket.setdefaulttimeout(timeout)
|
||||||
|
|
||||||
|
# Fill in some headers
|
||||||
|
if not headers.get('Referer'):
|
||||||
|
headers['Referer'] = urlparse(url).hostname
|
||||||
|
if not headers.get('User-Agent'):
|
||||||
|
headers['User-Agent'] = ''
|
||||||
|
|
||||||
host = urlparse(url).hostname
|
host = urlparse(url).hostname
|
||||||
self.wait(host)
|
self.wait(host)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.helpers.request import jsonified, getParam
|
from couchpotato.core.helpers.request import jsonified, getParam, getParams
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
@@ -14,6 +14,7 @@ class Logging(Plugin):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
addApiView('logging.get', self.get)
|
addApiView('logging.get', self.get)
|
||||||
addApiView('logging.clear', self.clear)
|
addApiView('logging.clear', self.clear)
|
||||||
|
addApiView('logging.log', self.log)
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
|
|
||||||
@@ -67,3 +68,21 @@ class Logging(Plugin):
|
|||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def log(self):
|
||||||
|
|
||||||
|
params = getParams()
|
||||||
|
|
||||||
|
try:
|
||||||
|
log_message = 'API log: %s' % params
|
||||||
|
try:
|
||||||
|
getattr(log, params.get('type', 'error'))(log_message)
|
||||||
|
except:
|
||||||
|
log.error(log_message)
|
||||||
|
except:
|
||||||
|
log.error('Couldn\'t log via API: %s' % params)
|
||||||
|
|
||||||
|
|
||||||
|
return jsonified({
|
||||||
|
'success': True
|
||||||
|
})
|
||||||
@@ -23,7 +23,7 @@ class X264(NZBProvider):
|
|||||||
if self.isDisabled() or not self.isAvailable(self.urls['search']) or not quality.get('hd', False):
|
if self.isDisabled() or not self.isAvailable(self.urls['search']) or not quality.get('hd', False):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
q = '%s %s' % (movie['library']['titles'][0]['title'], quality.get('identifier'))
|
q = '%s %s %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], quality.get('identifier'))
|
||||||
url = self.urls['search'] % quote_plus(q)
|
url = self.urls['search'] % quote_plus(q)
|
||||||
|
|
||||||
cache_key = 'x264.%s' % q
|
cache_key = 'x264.%s' % q
|
||||||
|
|||||||
@@ -52,6 +52,22 @@
|
|||||||
'is_remote': false
|
'is_remote': false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Catch errors
|
||||||
|
window.onerror = function(message, file, line){
|
||||||
|
|
||||||
|
Api.request('logging.log', {
|
||||||
|
'data': {
|
||||||
|
'type': 'error',
|
||||||
|
'message': Browser.name + ' ' + Browser.version + ': \n' + message,
|
||||||
|
'page': window.location.href,
|
||||||
|
'file': file,
|
||||||
|
'line': line
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Quality.setup({
|
Quality.setup({
|
||||||
'profiles': {{ fireEvent('profile.all', single = True)|tojson|safe }},
|
'profiles': {{ fireEvent('profile.all', single = True)|tojson|safe }},
|
||||||
'qualities': {{ fireEvent('quality.all', single = True)|tojson|safe }}
|
'qualities': {{ fireEvent('quality.all', single = True)|tojson|safe }}
|
||||||
|
|||||||
Reference in new issue
Block a user