diff --git a/hbd/server/notify.py b/hbd/server/notify.py index 8b401d2..a44067e 100644 --- a/hbd/server/notify.py +++ b/hbd/server/notify.py @@ -106,11 +106,18 @@ def closelog(): def eventlog(host, lvl, m, service=None): ts = time.time() + msg = { + "ts": ts, + "host": host or None, + "level": lvl, + "service": service, + "message": m, + } + data.msgs.append(msg) s = f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(ts))} {lvl} " if host: s += f"{host} " s += m - data.msgs.append(s) logger.info(s) if logf: try: @@ -118,7 +125,7 @@ def eventlog(host, lvl, m, service=None): logf.flush() except Exception as e: logger.warning("failed to write to logfile: %s", e) - msg_to_websockets("message", s) + msg_to_websockets("message", msg) # --------------------------------------------------------------------------- diff --git a/hbd/server/templates/head.html b/hbd/server/templates/head.html index 4c90623..3167e90 100644 --- a/hbd/server/templates/head.html +++ b/hbd/server/templates/head.html @@ -214,7 +214,7 @@ ctx.restore(); } - hand((m + s / 60) / 60 * Math.PI * 2 - Math.PI / 2, + hand((sFrac >= 58.5 ? m + 1 : m) / 60 * Math.PI * 2 - Math.PI / 2, R * 0.88, -R * 0.12, SIZE * 0.027, '#222'); /* minute */ hand((h + m / 60) / 12 * Math.PI * 2 - Math.PI / 2, R * 0.58, -R * 0.12, SIZE * 0.039, '#222'); /* hour */ diff --git a/hbd/server/templates/live.html b/hbd/server/templates/live.html index 60396b3..a5fb356 100644 --- a/hbd/server/templates/live.html +++ b/hbd/server/templates/live.html @@ -183,11 +183,24 @@ line-height: 1.0; } - #messages div { + #messages .log-entry { padding: 5px 0; border-bottom: 1px solid #f0f0f0; + display: flex; + gap: 0.5em; + align-items: baseline; } + .log-ts { color: #888; white-space: nowrap; } + .log-level { font-weight: bold; min-width: 6em; } + .log-host { font-weight: 600; } + .log-service { color: #888; } + + .log-warning .log-level { color: #b8860b; } + .log-critical .log-level { color: #c00; } + .log-recover .log-level { color: #2a7a2a; } + .log-info .log-level { color: #555; } + /* Modal for connection status messages */ .connection-modal { display: none; @@ -460,7 +473,17 @@ update_table(state.data); } else if (state.type == "message") { var msgs = document.getElementById("messages"); - msgs.insertAdjacentHTML("afterbegin", "