fix [Feature]: 新增系统日志表(logs),软件包可以主动记录日志(错误、警告、信息) #6571

This commit is contained in:
baozhoutao 2024-03-10 14:29:10 +08:00
parent d4724f9b2f
commit 80aca3e2ad
7 changed files with 55 additions and 3 deletions

1
.gitignore vendored
View File

@ -29,6 +29,7 @@
!/server/bundle/**/node_modules/formBuilder/dist !/server/bundle/**/node_modules/formBuilder/dist
!/server/bundle/**/node_modules/@steedos/form-builder/dist !/server/bundle/**/node_modules/@steedos/form-builder/dist
!/server/bundle/**/node_modules !/server/bundle/**/node_modules
!services/standard-space/main/default/objects/logs
docker-volumes/** docker-volumes/**
examples/multi-node-testing/** examples/multi-node-testing/**

View File

@ -1,8 +1,8 @@
/* /*
* @Author: sunhaolin@hotoa.com * @Author: sunhaolin@hotoa.com
* @Date: 2023-03-23 15:12:14 * @Date: 2023-03-23 15:12:14
* @LastEditors: 孙浩林 sunhaolin@steedos.com * @LastEditors: baozhoutao@steedos.com
* @LastEditTime: 2023-11-14 10:27:19 * @LastEditTime: 2024-03-10 14:28:36
* @Description: * @Description:
*/ */
"use strict"; "use strict";
@ -407,8 +407,45 @@ module.exports = {
async handler() { async handler() {
return await this.broker.call("objectql.makeNewID") 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
})
}
}
}
} }
}, },
/** /**

View File

@ -0,0 +1,5 @@
name: details
type: code
language: ini
is_wide: true
sort_no: 200

View File

@ -0,0 +1,3 @@
name: level
type: text
sort_no: 120

View File

@ -0,0 +1,3 @@
name: name
type: text
sort_no: 100

View File

@ -0,0 +1,2 @@
name: node_id
type: text

View File

@ -0,0 +1 @@
name: logs