Merge branch 'master' into 6533_myLogger_salix
gitea/mylogger/pipeline/pr-master This commit looks good
Details
gitea/mylogger/pipeline/pr-master This commit looks good
Details
This commit is contained in:
commit
970744c3b1
|
@ -4,6 +4,7 @@ logMainShowField: false
|
|||
upperCaseTable: true
|
||||
userField: editorFk
|
||||
rowExcludeField: logExclude
|
||||
ignoreSystem: false
|
||||
excludeRegex: '__$'
|
||||
showFields:
|
||||
- name
|
||||
|
@ -23,6 +24,7 @@ logs:
|
|||
- itemTag
|
||||
- name: item
|
||||
showField: name
|
||||
showId: id
|
||||
logFields:
|
||||
- size
|
||||
exclude:
|
||||
|
|
|
@ -99,7 +99,8 @@ module.exports = class ModelLoader {
|
|||
];
|
||||
const globalProps = [
|
||||
'userField',
|
||||
'rowExcludeField'
|
||||
'rowExcludeField',
|
||||
'ignoreSystem'
|
||||
];
|
||||
|
||||
for (const [schema, table, tableInfo] of schemaMap) {
|
||||
|
|
21
mylogger.js
21
mylogger.js
|
@ -94,7 +94,8 @@ module.exports = class MyLogger {
|
|||
oldInstance = ?,
|
||||
newInstance = ?,
|
||||
changedModelId = ?,
|
||||
changedModelValue = ?`
|
||||
changedModelValue = ?,
|
||||
summaryId = ?`
|
||||
);
|
||||
logInfo.fetchStmt = await db.prepare(
|
||||
`SELECT id FROM ${sqlTable}
|
||||
|
@ -109,7 +110,8 @@ module.exports = class MyLogger {
|
|||
SET originFk = ?,
|
||||
creationDate = ?,
|
||||
oldInstance = ?,
|
||||
changedModelValue = ?
|
||||
changedModelValue = ?,
|
||||
summaryId = ?
|
||||
WHERE id = ?`
|
||||
);
|
||||
}
|
||||
|
@ -271,7 +273,7 @@ module.exports = class MyLogger {
|
|||
}
|
||||
}
|
||||
|
||||
async onError(err) {
|
||||
async handleError(err) {
|
||||
if (!this.isOk) return;
|
||||
this.isOk = false;
|
||||
console.log(`Error: ${err.code}: ${err.message}`);
|
||||
|
@ -291,10 +293,6 @@ module.exports = class MyLogger {
|
|||
}
|
||||
}
|
||||
|
||||
handleError(err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
async onBinlog(evt) {
|
||||
//evt.dump();
|
||||
try {
|
||||
|
@ -332,14 +330,16 @@ module.exports = class MyLogger {
|
|||
const table = evt.tableMap[evt.tableId];
|
||||
const tableName = table.tableName;
|
||||
const tableInfo = this.schemaMap.get(table.parentSchema, tableName);
|
||||
|
||||
if (!tableInfo) return;
|
||||
|
||||
const action = actions[eventName];
|
||||
const { rowExcludeField } = tableInfo;
|
||||
const { rowExcludeField, ignoreSystem } = tableInfo;
|
||||
const changes = [];
|
||||
|
||||
function isExcluded(row) {
|
||||
return rowExcludeField && row[rowExcludeField];
|
||||
return (rowExcludeField && row[rowExcludeField])
|
||||
|| (ignoreSystem && row.editorFk == null);
|
||||
}
|
||||
|
||||
function cast(value, type) {
|
||||
|
@ -500,6 +500,7 @@ module.exports = class MyLogger {
|
|||
const isDelete = action == 'delete';
|
||||
const isUpdate = action == 'update';
|
||||
const created = new Date(evt.timestamp);
|
||||
const showId = tableInfo.conf.showId;
|
||||
|
||||
for (const change of changes) {
|
||||
let newI, oldI;
|
||||
|
@ -521,7 +522,7 @@ module.exports = class MyLogger {
|
|||
oldI = change.instance;
|
||||
break;
|
||||
}
|
||||
|
||||
const summaryId = showId ? row[showId] : null;
|
||||
const modelId = row[tableInfo.idName];
|
||||
const modelValue = change.modelValue ?? null;
|
||||
const oldInstance = oldI ? JSON.stringify(oldI) : null;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mylogger",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "MySQL and MariaDB logger using binary log",
|
||||
"license": "GPL-3.0",
|
||||
|
|
Loading…
Reference in New Issue