mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 01:02:19 +00:00
Implemented empty and download log
This commit is contained in:
parent
a690754df7
commit
422b27ef6f
2 changed files with 34 additions and 1 deletions
17
bazarr.py
17
bazarr.py
|
@ -65,6 +65,7 @@ class OneLineExceptionFormatter(logging.Formatter):
|
|||
return s
|
||||
|
||||
def configure_logging():
|
||||
global fh
|
||||
fh = TimedRotatingFileHandler(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log'), when="midnight", interval=1, backupCount=7)
|
||||
f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',
|
||||
'%d/%m/%Y %H:%M:%S')
|
||||
|
@ -78,6 +79,7 @@ def configure_logging():
|
|||
|
||||
configure_logging()
|
||||
|
||||
|
||||
@route('/')
|
||||
def redirect_root():
|
||||
redirect (base_url)
|
||||
|
@ -86,6 +88,19 @@ def redirect_root():
|
|||
def static(path):
|
||||
return static_file(path, root=os.path.join(os.path.dirname(__file__), 'static'))
|
||||
|
||||
@route(base_url + 'emptylog')
|
||||
def emptylog():
|
||||
ref = request.environ['HTTP_REFERER']
|
||||
|
||||
fh.doRollover()
|
||||
logging.info('Log file emptied')
|
||||
|
||||
redirect(ref)
|
||||
|
||||
@route(base_url + 'bazarr.log')
|
||||
def download_log():
|
||||
return static_file('bazarr.log', root='data/log/', download='bazarr.log')
|
||||
|
||||
@route(base_url + 'image_proxy/<url:path>', method='GET')
|
||||
def image_proxy(url):
|
||||
img_pil = Image.open(BytesIO(requests.get(url_sonarr_short + '/' + url).content))
|
||||
|
@ -493,4 +508,6 @@ def get_subtitle():
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
|
||||
run(host=ip, port=port, server='waitress')
|
||||
logging.info('Bazarr has been stopped.')
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
margin-bottom: 3em;
|
||||
padding: 1em;
|
||||
}
|
||||
#logs {
|
||||
margin-top: 4em;
|
||||
}
|
||||
.fast.backward, .backward, .forward, .fast.forward {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -111,6 +114,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="ui bottom attached tab segment" data-tab="logs">
|
||||
<div class="ui right floated basic buttons">
|
||||
<button id="download_log" class="ui button"><i class="download icon"></i>Download log file</button>
|
||||
<button id="empty_log" class="ui button"><i class="download icon"></i>Empty log file</button>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div id="logs"></div>
|
||||
|
||||
|
@ -182,11 +190,19 @@
|
|||
loadURL({{int(max_page)}});
|
||||
})
|
||||
|
||||
$('#download_log').click(function(){
|
||||
window.location = '{{base_url}}bazarr.log';
|
||||
})
|
||||
|
||||
$('#empty_log').click(function(){
|
||||
window.location = '{{base_url}}emptylog';
|
||||
})
|
||||
|
||||
$('.execute').click(function(){
|
||||
window.location = '{{base_url}}execute/' + $(this).data("taskid");
|
||||
})
|
||||
|
||||
$('a:not(.tabs), button:not(.cancel)').click(function(){
|
||||
$('a:not(.tabs), button:not(.cancel, #download_log)').click(function(){
|
||||
$('#loader').addClass('active');
|
||||
})
|
||||
</script>
|
Loading…
Reference in a new issue