Add remote console capabilities
This commit is contained in:
45
remote_console/_studio_dependencies/console.js
Normal file
45
remote_console/_studio_dependencies/console.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { recognizedObject: r = {} } = this;
|
||||
|
||||
class WebdisConsole {
|
||||
constructor() {}
|
||||
|
||||
log(...data) {
|
||||
this.info(data);
|
||||
}
|
||||
|
||||
debug(...data) {
|
||||
this.#log("DEBUG", data);
|
||||
}
|
||||
|
||||
info(...data) {
|
||||
this.#log("INFO", data);
|
||||
}
|
||||
|
||||
warn(...data) {
|
||||
this.#log("WARN", data);
|
||||
}
|
||||
|
||||
error(...data) {
|
||||
this.#log("ERROR", data);
|
||||
}
|
||||
|
||||
#log(level, ...data) {
|
||||
webdis()
|
||||
.publish(r.workspaceId + ".console", {
|
||||
conversationId: r.conversationId,
|
||||
data: JSON.stringify(data),
|
||||
level: level,
|
||||
})
|
||||
.catch((error) => {
|
||||
r.errorInfo = {
|
||||
...r.errorInfo,
|
||||
label: {
|
||||
data: error.toJSON ? error.toJSON() : {},
|
||||
message: error.message,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return new WebdisConsole();
|
||||
Reference in New Issue
Block a user