From 80aca3e2ad209674f73095e580ab2bb8e2a2a1cc Mon Sep 17 00:00:00 2001 From: baozhoutao Date: Sun, 10 Mar 2024 14:29:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=20[Feature]:=20=E6=96=B0=E5=A2=9E=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=97=A5=E5=BF=97=E8=A1=A8(logs)=EF=BC=8C=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E5=8C=85=E5=8F=AF=E4=BB=A5=E4=B8=BB=E5=8A=A8=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97=EF=BC=88=E9=94=99=E8=AF=AF=E3=80=81?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=E3=80=81=E4=BF=A1=E6=81=AF=EF=BC=89=20#6571?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../service-object-mixin/package.service.js | 43 +++++++++++++++++-- .../objects/logs/fields/details.field.yml | 5 +++ .../objects/logs/fields/level.field.yml | 3 ++ .../objects/logs/fields/name.field.yml | 3 ++ .../objects/logs/fields/node_id.field.yml | 2 + .../main/default/objects/logs/logs.object.yml | 1 + 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 services/standard-space/main/default/objects/logs/fields/details.field.yml create mode 100644 services/standard-space/main/default/objects/logs/fields/level.field.yml create mode 100644 services/standard-space/main/default/objects/logs/fields/name.field.yml create mode 100644 services/standard-space/main/default/objects/logs/fields/node_id.field.yml create mode 100644 services/standard-space/main/default/objects/logs/logs.object.yml diff --git a/.gitignore b/.gitignore index 714b89eedb..acc7394799 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ !/server/bundle/**/node_modules/formBuilder/dist !/server/bundle/**/node_modules/@steedos/form-builder/dist !/server/bundle/**/node_modules +!services/standard-space/main/default/objects/logs docker-volumes/** examples/multi-node-testing/** diff --git a/services/service-object-mixin/package.service.js b/services/service-object-mixin/package.service.js index c839a4483c..48984334af 100644 --- a/services/service-object-mixin/package.service.js +++ b/services/service-object-mixin/package.service.js @@ -1,8 +1,8 @@ /* * @Author: sunhaolin@hotoa.com * @Date: 2023-03-23 15:12:14 - * @LastEditors: 孙浩林 sunhaolin@steedos.com - * @LastEditTime: 2023-11-14 10:27:19 + * @LastEditors: baozhoutao@steedos.com + * @LastEditTime: 2024-03-10 14:28:36 * @Description: */ "use strict"; @@ -407,8 +407,45 @@ module.exports = { async handler() { return await this.broker.call("objectql.makeNewID") } + }, + getLog: { + handler: function () { + return { + debug: async function(message, details){ + return await this.getObject('logs').directInsert({ + 'level': 'debug', + 'name': message, + 'details': details, + 'node_id': this.broker.nodeID + }) + }, + info: async function(message, details){ + return await this.getObject('logs').directInsert({ + 'level': 'info', + 'name': message, + 'details': details, + 'node_id': this.broker.nodeID + }) + }, + warn: async function(message, details){ + return await this.getObject('logs').directInsert({ + 'level': 'warn', + 'name': message, + 'details': details, + 'node_id': this.broker.nodeID + }) + }, + error: async function(message, details){ + return await this.getObject('logs').directInsert({ + 'level': 'error', + 'name': message, + 'details': details, + 'node_id': this.broker.nodeID + }) + } + } + } } - }, /** diff --git a/services/standard-space/main/default/objects/logs/fields/details.field.yml b/services/standard-space/main/default/objects/logs/fields/details.field.yml new file mode 100644 index 0000000000..9b49c8f6a5 --- /dev/null +++ b/services/standard-space/main/default/objects/logs/fields/details.field.yml @@ -0,0 +1,5 @@ +name: details +type: code +language: ini +is_wide: true +sort_no: 200 \ No newline at end of file diff --git a/services/standard-space/main/default/objects/logs/fields/level.field.yml b/services/standard-space/main/default/objects/logs/fields/level.field.yml new file mode 100644 index 0000000000..a50f6a74a8 --- /dev/null +++ b/services/standard-space/main/default/objects/logs/fields/level.field.yml @@ -0,0 +1,3 @@ +name: level +type: text +sort_no: 120 \ No newline at end of file diff --git a/services/standard-space/main/default/objects/logs/fields/name.field.yml b/services/standard-space/main/default/objects/logs/fields/name.field.yml new file mode 100644 index 0000000000..9d3cbd1923 --- /dev/null +++ b/services/standard-space/main/default/objects/logs/fields/name.field.yml @@ -0,0 +1,3 @@ +name: name +type: text +sort_no: 100 \ No newline at end of file diff --git a/services/standard-space/main/default/objects/logs/fields/node_id.field.yml b/services/standard-space/main/default/objects/logs/fields/node_id.field.yml new file mode 100644 index 0000000000..d468a8e6a1 --- /dev/null +++ b/services/standard-space/main/default/objects/logs/fields/node_id.field.yml @@ -0,0 +1,2 @@ +name: node_id +type: text \ No newline at end of file diff --git a/services/standard-space/main/default/objects/logs/logs.object.yml b/services/standard-space/main/default/objects/logs/logs.object.yml new file mode 100644 index 0000000000..f13a0d8763 --- /dev/null +++ b/services/standard-space/main/default/objects/logs/logs.object.yml @@ -0,0 +1 @@ +name: logs \ No newline at end of file