add max-lines

This commit is contained in:
dadav 2020-04-17 20:18:12 +02:00
parent d1411ffa96
commit fa87e03222
2 changed files with 4 additions and 2 deletions

View File

@ -110,6 +110,7 @@ main.plugins.led.patterns.peer_detected = "oo oo oo oo oo oo oo"
main.plugins.led.patterns.peer_lost = "oo oo oo oo oo oo oo" main.plugins.led.patterns.peer_lost = "oo oo oo oo oo oo oo"
main.plugins.logtail.enabled = false main.plugins.logtail.enabled = false
main.plugins.logtail.max-lines = 10000
main.plugins.session-stats.enabled = true main.plugins.session-stats.enabled = true
main.plugins.session-stats.save_directory = "/var/tmp/pwnagotchi/sessions/" main.plugins.session-stats.save_directory = "/var/tmp/pwnagotchi/sessions/"

View File

@ -207,12 +207,12 @@ TEMPLATE = """
} }
document.body.style.cursor = 'default'; document.body.style.cursor = 'default';
} }
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="sticky"> <div class="sticky">
<input type="text" id="filter" placeholder="Search for ..." title="Type in a filter"> <input type="text" id="filter" placeholder="Search for ..." title="Type in a filter">
<span><input type="button" id="clear" value="Clear"></span>
<span><input checked type="checkbox" id="autoscroll"></span> <span><input checked type="checkbox" id="autoscroll"></span>
<span><label for="autoscroll"> Autoscroll to bottom</label><br></span> <span><label for="autoscroll"> Autoscroll to bottom</label><br></span>
</div> </div>
@ -254,6 +254,7 @@ class Logtail(plugins.Plugin):
""" """
logging.info("Logtail plugin loaded.") logging.info("Logtail plugin loaded.")
def on_webhook(self, path, request): def on_webhook(self, path, request):
if not self.ready: if not self.ready:
return "Plugin not ready" return "Plugin not ready"
@ -266,7 +267,7 @@ class Logtail(plugins.Plugin):
with open(self.config['main']['log']['path']) as f: with open(self.config['main']['log']['path']) as f:
# https://stackoverflow.com/questions/39549426/read-multiple-lines-from-a-file-batch-by-batch/39549901#39549901 # https://stackoverflow.com/questions/39549426/read-multiple-lines-from-a-file-batch-by-batch/39549901#39549901
n = 1024 n = 1024
for n_lines in iter(lambda: ''.join(islice(f, n)), ''): for n_lines in iter(lambda: ''.join(islice(list(f)[-self.options.get('max-lines', 10000):], n)), ''):
yield n_lines yield n_lines
while True: while True:
yield f.readline() yield f.readline()