Skip to content

Commit

Permalink
Merge pull request #20 from DewGew/DewGew-logger
Browse files Browse the repository at this point in the history
  • Loading branch information
DewGew authored Oct 19, 2023
2 parents 4fbfcb6 + 5cc0cb3 commit 9d39390
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 1 addition & 3 deletions modules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
import string
import modules.config as config

# Enable log in config.py if need #
# if hasattr(config, 'LOG_FILE'):
# Logging
logging.basicConfig(level=logging.DEBUG,
format="%(asctime)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
filename=os.path.join(config.CONFIG_DIRECTORY, "smarthome.log"),
filemode='w')
logging.getLogger().addHandler(logging.StreamHandler())
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger('werkzeug').setLevel(logging.ERROR)
logger = logging.getLogger()

Expand Down
2 changes: 1 addition & 1 deletion smarthome.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def generate():
with open(filename) as f:
while True:
yield f.read()
sleep(1)
sleep(0.5)
return Response(generate(), mimetype='text/plain')

@app.route('/devices')
Expand Down
2 changes: 1 addition & 1 deletion templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- Vendor JS Files -->
<script src="static/vendor/apexcharts/apexcharts.min.js"></script>
<script src="static/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="static/vendor/chart.js/chart.umd.js"></script>
<!-- <script src="static/vendor/chart.js/chart.umd.js"></script> -->
<script src="static/vendor/echarts/echarts.min.js"></script>
<script src="static/vendor/quill/quill.min.js"></script>
<script src="static/vendor/simple-datatables/simple-datatables.js"></script>
Expand Down
19 changes: 18 additions & 1 deletion templates/logging.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ <h1>Logs</h1>

<div class="card-body">
<h5 class="card-title">Logs <span>| {{ user }}</span></h5>
<iframe class="logging_window"
<iframe class="logging_window" id="logging_window"
src="{{ url_for('stream')}}">
</iframe>
</br>
<form class="form-check form-switch">
<label><input class="form-check-input" type="checkbox" value="AutoScroll" id="autoScroll" label="Auto Scroll">Auto-Scroll</label>
</form>
</div>
</div>

Expand All @@ -68,3 +72,16 @@ <h5 class="card-title">Logs <span>| {{ user }}</span></h5>
</main><!-- End #main -->

{% include 'footer.html' %}
<script>
$(document).ready(function() {
//set initial state.
$('#autoScroll').val(this.checked);

$('#autoScroll').change(function() {
if(this.checked) {
setInterval('frames[0].scrollTo(0,9999999)',1000)
}
$('#autoScroll').val(this.checked);
});
});
</script>

0 comments on commit 9d39390

Please sign in to comment.