smart-home-engine 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-DqPNasAj.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-ByoSXq9N.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -172,10 +172,10 @@
172
172
  }
173
173
  })();
174
174
  </script>
175
- <script type="module" crossorigin src="/assets/index-DqPNasAj.js"></script>
175
+ <script type="module" crossorigin src="/assets/index-ByoSXq9N.js"></script>
176
176
  <link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
177
177
  <link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
178
- <link rel="stylesheet" crossorigin href="/assets/index-D_NqSYjh.css">
178
+ <link rel="stylesheet" crossorigin href="/assets/index-D3e4KUzX.css">
179
179
  </head>
180
180
  <body>
181
181
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "Node.js based script runner for use in MQTT based Smart Home environments",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -25,6 +25,7 @@ const mosquittoConf = require('../lib/mosquitto-conf');
25
25
  const ca = require('../lib/ca');
26
26
  const sshDeploy = require('../lib/ssh-deploy');
27
27
  const sheConfig = require('../config');
28
+ const { getBrokerLogBuffer } = require('./log-ws');
28
29
 
29
30
  // Default SSH identity file respects the configured data directory
30
31
  const DEFAULT_SSH_KEY = path.join(sheConfig['data-dir'], 'ssh', 'broker_id_ed25519');
@@ -938,6 +939,13 @@ router.post('/ca/trusted/addpath', async (req, res) => {
938
939
  }
939
940
  });
940
941
 
942
+ // GET /she/broker/logs?limit=<N> — recent broker log entries (ring buffer, max 500)
943
+ router.get('/logs', (req, res) => {
944
+ const limit = Math.min(Number(req.query.limit) || 500, 1000);
945
+ const all = getBrokerLogBuffer();
946
+ res.json(limit >= all.length ? all : all.slice(-limit));
947
+ });
948
+
941
949
  module.exports = { router, setLogger, setStore };
942
950
 
943
951
  // ── dynsec: ACL topic inspection ──────────────────────────────────────────────
package/src/web/log-ws.js CHANGED
@@ -97,14 +97,28 @@ function getLogBuffer() {
97
97
  /**
98
98
  * Broadcast a structured broker (mosquitto) log entry to all connected
99
99
  * WebSocket clients as { type: 'brokerLog', level, msg, ts }.
100
+ * Also stores the entry in a server-side ring buffer exposed via getBrokerLogBuffer().
100
101
  * @param {string} level Single-letter mosquitto level: D|I|N|W|E
101
102
  * @param {string} msg
102
103
  * @param {number} ts Unix ms timestamp
103
104
  */
105
+ const _brokerLogBuffer = [];
106
+ const BROKER_LOG_BUFFER_MAX = 500;
107
+
104
108
  function broadcastBrokerLog(level, msg, ts) {
109
+ _brokerLogBuffer.push({ level, msg, ts });
110
+ if (_brokerLogBuffer.length > BROKER_LOG_BUFFER_MAX) _brokerLogBuffer.shift();
105
111
  broadcast({ type: 'brokerLog', level, msg, ts });
106
112
  }
107
113
 
114
+ /**
115
+ * Return a snapshot of recent broker log entries (oldest first).
116
+ * @returns {{ level: string, msg: string, ts: number }[]}
117
+ */
118
+ function getBrokerLogBuffer() {
119
+ return _brokerLogBuffer.slice();
120
+ }
121
+
108
122
  /**
109
123
  * Close the WebSocket server.
110
124
  * @returns {Promise<void>}
@@ -120,4 +134,4 @@ function closeWss() {
120
134
  });
121
135
  }
122
136
 
123
- module.exports = { attachWss, broadcast, broadcastBrokerLog, broadcastLog, closeWss, getLogBuffer, setWelcomeProvider };
137
+ module.exports = { attachWss, broadcast, broadcastBrokerLog, broadcastLog, closeWss, getBrokerLogBuffer, getLogBuffer, setWelcomeProvider };