mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
SYNC: Merge pull request #7 from dbgate/feature/applog
This commit is contained in:
@@ -79,7 +79,7 @@ export class DatabaseAnalyser<TClient = any> {
|
||||
|
||||
async fullAnalysis() {
|
||||
logger.debug(
|
||||
`Performing full analysis, DB=${dbNameLogCategory(this.dbhan.database)}, engine=${this.driver.engine}`
|
||||
`DBGM-00126 Performing full analysis, DB=${dbNameLogCategory(this.dbhan.database)}, engine=${this.driver.engine}`
|
||||
);
|
||||
const res = this.addEngineField(await this._runAnalysis());
|
||||
// console.log('FULL ANALYSIS', res);
|
||||
@@ -102,7 +102,7 @@ export class DatabaseAnalyser<TClient = any> {
|
||||
|
||||
async incrementalAnalysis(structure) {
|
||||
logger.info(
|
||||
`Performing incremental analysis, DB=${dbNameLogCategory(this.dbhan.database)}, engine=${this.driver.engine}`
|
||||
`DBGM-00127 Performing incremental analysis, DB=${dbNameLogCategory(this.dbhan.database)}, engine=${this.driver.engine}`
|
||||
);
|
||||
this.structure = structure;
|
||||
|
||||
@@ -129,7 +129,7 @@ export class DatabaseAnalyser<TClient = any> {
|
||||
|
||||
this.modifications = structureModifications;
|
||||
if (structureWithRowCounts) this.structure = structureWithRowCounts;
|
||||
logger.info({ modifications: this.modifications }, 'DB modifications detected:');
|
||||
logger.info({ modifications: this.modifications }, 'DBGM-00128 DB modifications detected:');
|
||||
return this.addEngineField(this.mergeAnalyseResult(await this._runAnalysis()));
|
||||
}
|
||||
|
||||
@@ -347,10 +347,10 @@ export class DatabaseAnalyser<TClient = any> {
|
||||
}
|
||||
try {
|
||||
const res = await this.driver.query(this.dbhan, sql);
|
||||
this.logger.debug({ rows: res.rows.length, template }, `Loaded analyser query`);
|
||||
this.logger.debug({ rows: res.rows.length, template }, `DBGM-00129 Loaded analyser query`);
|
||||
return res;
|
||||
} catch (err) {
|
||||
logger.error(extractErrorLogData(err, { template }), 'Error running analyser query');
|
||||
logger.error(extractErrorLogData(err, { template }), 'DBGM-00130 Error running analyser query');
|
||||
return {
|
||||
rows: [],
|
||||
isError: true,
|
||||
|
||||
@@ -93,7 +93,7 @@ export class SqlGenerator {
|
||||
}
|
||||
|
||||
private handleException = error => {
|
||||
logger.error(extractErrorLogData(error), 'Unhandled error');
|
||||
logger.error(extractErrorLogData(error), 'DBGM-00186 Unhandled error');
|
||||
this.isUnhandledException = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,20 +41,20 @@ export function createBulkInsertStreamBase(driver: EngineDriver, stream, dbhan,
|
||||
writable.structure = structure;
|
||||
}
|
||||
if (structure && options.dropIfExists) {
|
||||
logger.info(`Dropping table ${fullNameQuoted}`);
|
||||
logger.info(`DBGM-00123 Dropping table ${fullNameQuoted}`);
|
||||
await driver.script(dbhan, `DROP TABLE ${fullNameQuoted}`);
|
||||
}
|
||||
if (options.createIfNotExists && (!structure || options.dropIfExists)) {
|
||||
const dmp = driver.createDumper();
|
||||
const createdTableInfo = driver.adaptTableInfo(prepareTableForImport({ ...writable.structure, ...name }));
|
||||
dmp.createTable(createdTableInfo);
|
||||
logger.info({ sql: dmp.s }, `Creating table ${fullNameQuoted}`);
|
||||
logger.info({ sql: dmp.s }, `DBGM-00124 Creating table ${fullNameQuoted}`);
|
||||
await driver.script(dbhan, dmp.s);
|
||||
structure = await driver.analyseSingleTable(dbhan, name);
|
||||
writable.structure = structure;
|
||||
}
|
||||
if (!writable.structure) {
|
||||
throw new Error(`Error importing table - ${fullNameQuoted} not found`);
|
||||
throw new Error(`DBGM-00125 Error importing table - ${fullNameQuoted} not found`);
|
||||
}
|
||||
if (options.truncate) {
|
||||
await driver.script(dbhan, `TRUNCATE TABLE ${fullNameQuoted}`);
|
||||
@@ -71,7 +71,7 @@ export function createBulkInsertStreamBase(driver: EngineDriver, stream, dbhan,
|
||||
])
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(extractErrorLogData(err), 'Error during preparing bulk insert table, stopped');
|
||||
logger.error(extractErrorLogData(err), 'DBGM-00184 Error during preparing bulk insert table, stopped');
|
||||
writable.destroy(err);
|
||||
}
|
||||
};
|
||||
@@ -129,7 +129,7 @@ export function createBulkInsertStreamBase(driver: EngineDriver, stream, dbhan,
|
||||
await driver.query(dbhan, dmp.s, { discardResult: true });
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(extractErrorLogData(err), 'Error during base bulk insert, insert stopped');
|
||||
logger.error(extractErrorLogData(err), 'DBGM-00185 Error during base bulk insert, insert stopped');
|
||||
writable.destroy(err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ export const driverBase = {
|
||||
for (const sqlItem of splitQuery(sql, this.getQuerySplitterOptions('script'))) {
|
||||
try {
|
||||
if (options?.logScriptItems) {
|
||||
logger.info({ sql: getLimitedQuery(sqlItem as string) }, 'Execute script item');
|
||||
logger.info({ sql: getLimitedQuery(sqlItem as string) }, 'DBGM-00131 Execute script item');
|
||||
}
|
||||
await this.query(pool, sqlItem, { discardResult: true, ...options?.queryOptions });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user