refs #5541 Bugfixes, allow to set schema for log group
gitea/mylogger/pipeline/head This commit looks good
Details
gitea/mylogger/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c0c82564c4
commit
810fb55416
15
mylogger.js
15
mylogger.js
|
@ -26,15 +26,14 @@ module.exports = class MyLogger {
|
|||
Object.assign(conf, localConfig);
|
||||
}
|
||||
|
||||
const defaultSchema = conf.srcDb.database;
|
||||
function parseTable(tableString) {
|
||||
function parseTable(tableString, defaultSchema) {
|
||||
let name, schema;
|
||||
const split = tableString.split('.');
|
||||
if (split.length == 1) {
|
||||
name = split[0];
|
||||
schema = defaultSchema;
|
||||
} else {
|
||||
[name, schema] = split;
|
||||
[schema, name] = split;
|
||||
}
|
||||
return {name, schema};
|
||||
}
|
||||
|
@ -43,7 +42,7 @@ module.exports = class MyLogger {
|
|||
function addTable(tableConf, logInfo) {
|
||||
if (typeof tableConf == 'string')
|
||||
tableConf = {name: tableConf};
|
||||
const table = parseTable(tableConf.name);
|
||||
const table = parseTable(tableConf.name, logInfo.schema);
|
||||
|
||||
let tableMap = schemaMap.get(table.schema);
|
||||
if (!tableMap) {
|
||||
|
@ -85,14 +84,16 @@ module.exports = class MyLogger {
|
|||
|
||||
for (const logName in conf.logs) {
|
||||
const logConf = conf.logs[logName];
|
||||
const schema = logConf.schema || conf.srcDb.database;
|
||||
const logInfo = {
|
||||
conf: logConf,
|
||||
table: parseTable(logConf.logTable),
|
||||
mainTable: parseTable(logConf.mainTable)
|
||||
schema,
|
||||
table: parseTable(logConf.logTable, schema),
|
||||
mainTable: parseTable(logConf.mainTable, schema)
|
||||
};
|
||||
this.logMap.set(logName, logInfo);
|
||||
|
||||
const mainTable = addTable(logInfo.mainTable, logInfo);
|
||||
const mainTable = addTable(logConf.mainTable, logInfo);
|
||||
mainTable.isMain = true;
|
||||
|
||||
if (logConf.tables)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "mylogger",
|
||||
"version": "0.1.13",
|
||||
"version": "0.1.14",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mylogger",
|
||||
"version": "0.1.13",
|
||||
"version": "0.1.14",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mylogger",
|
||||
"version": "0.1.13",
|
||||
"version": "0.1.14",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "MySQL and MariaDB logger using binary log",
|
||||
"license": "GPL-3.0",
|
||||
|
|
Loading…
Reference in New Issue