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
17
mylogger.js
17
mylogger.js
|
@ -26,15 +26,14 @@ module.exports = class MyLogger {
|
||||||
Object.assign(conf, localConfig);
|
Object.assign(conf, localConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultSchema = conf.srcDb.database;
|
function parseTable(tableString, defaultSchema) {
|
||||||
function parseTable(tableString) {
|
|
||||||
let name, schema;
|
let name, schema;
|
||||||
const split = tableString.split('.');
|
const split = tableString.split('.');
|
||||||
if (split.length == 1) {
|
if (split.length == 1) {
|
||||||
name = split[0];
|
name = split[0];
|
||||||
schema = defaultSchema;
|
schema = defaultSchema;
|
||||||
} else {
|
} else {
|
||||||
[name, schema] = split;
|
[schema, name] = split;
|
||||||
}
|
}
|
||||||
return {name, schema};
|
return {name, schema};
|
||||||
}
|
}
|
||||||
|
@ -42,8 +41,8 @@ module.exports = class MyLogger {
|
||||||
const schemaMap = this.schemaMap;
|
const schemaMap = this.schemaMap;
|
||||||
function addTable(tableConf, logInfo) {
|
function addTable(tableConf, logInfo) {
|
||||||
if (typeof tableConf == 'string')
|
if (typeof tableConf == 'string')
|
||||||
tableConf = {name: tableConf};
|
tableConf = {name: tableConf};
|
||||||
const table = parseTable(tableConf.name);
|
const table = parseTable(tableConf.name, logInfo.schema);
|
||||||
|
|
||||||
let tableMap = schemaMap.get(table.schema);
|
let tableMap = schemaMap.get(table.schema);
|
||||||
if (!tableMap) {
|
if (!tableMap) {
|
||||||
|
@ -85,14 +84,16 @@ module.exports = class MyLogger {
|
||||||
|
|
||||||
for (const logName in conf.logs) {
|
for (const logName in conf.logs) {
|
||||||
const logConf = conf.logs[logName];
|
const logConf = conf.logs[logName];
|
||||||
|
const schema = logConf.schema || conf.srcDb.database;
|
||||||
const logInfo = {
|
const logInfo = {
|
||||||
conf: logConf,
|
conf: logConf,
|
||||||
table: parseTable(logConf.logTable),
|
schema,
|
||||||
mainTable: parseTable(logConf.mainTable)
|
table: parseTable(logConf.logTable, schema),
|
||||||
|
mainTable: parseTable(logConf.mainTable, schema)
|
||||||
};
|
};
|
||||||
this.logMap.set(logName, logInfo);
|
this.logMap.set(logName, logInfo);
|
||||||
|
|
||||||
const mainTable = addTable(logInfo.mainTable, logInfo);
|
const mainTable = addTable(logConf.mainTable, logInfo);
|
||||||
mainTable.isMain = true;
|
mainTable.isMain = true;
|
||||||
|
|
||||||
if (logConf.tables)
|
if (logConf.tables)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "mylogger",
|
"name": "mylogger",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mylogger",
|
"name": "mylogger",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mylogger",
|
"name": "mylogger",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL and MariaDB logger using binary log",
|
"description": "MySQL and MariaDB logger using binary log",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue