Skip to content

Commit 5f4d9dc

Browse files
committed
feat: add description to subscribe nodes for better logging
1 parent 4b7f55a commit 5f4d9dc

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/nodes/openware-subscription/openware-subscription.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const nodeInit: NodeInitializer = (RED): void => {
7272
node.send([null, { payload: { connected: true } }]);
7373
}
7474
},
75+
description: JSON.stringify(msg.query!.sensorInfos),
7576
});
7677
node.status({
7778
fill: "yellow",

src/nodes/shared/initApi.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ export async function initApi(node: ConfigNode) {
223223
const addSubscription = (sub: WSSubscription) => {
224224
const id = "ID_" + Math.random().toString(16);
225225
node.subscriptions[id] = sub;
226-
console.log("Subscriptions", node.subscriptions);
226+
console.log("Added subscription", id, sub["description" as keyof WSSubscription] || "");
227+
console.log("Subscriptions", JSON.stringify(node.subscriptions, null, 2));
227228
return () => {
228229
delete node.subscriptions[id];
229230
};

src/nodes/shared/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface WSSubscription {
7474
onMessage: (message: any) => void;
7575
onStatus: (status: StatusMessage) => void;
7676
filter: (message: any) => boolean;
77+
description?: string;
7778
}
7879

7980
export type ConfigNode = Node & {

0 commit comments

Comments
 (0)