chore: database debug logging

This commit is contained in:
Chareice 2024-04-26 10:52:35 +08:00
parent 16458ab538
commit e3408c9ff1
No known key found for this signature in database
2 changed files with 11 additions and 2 deletions

View File

@ -320,7 +320,11 @@ export class Collection<
const { database } = this.context;
database.logger.debug(`beforeSetField: ${this.name}, ${name}, ${safeJsonStringify(options)}`);
database.logger.debug(`beforeSetField: ${safeJsonStringify(options)}`, {
databaseInstanceId: database.instanceId,
collectionName: this.name,
fieldName: name,
});
if (options.source) {
const [sourceCollectionName, sourceFieldName] = options.source.split('.');

View File

@ -261,6 +261,9 @@ export class Database extends EventEmitter implements AsyncEmitter {
}
this.options = opts;
this.logger.debug(`create database instance: ${safeJsonStringify(this.options)}`, {
databaseInstanceId: this.instanceId,
});
const sequelizeOptions = this.sequelizeOptions(this.options);
this.sequelize = new Sequelize(sequelizeOptions);
@ -538,7 +541,9 @@ export class Database extends EventEmitter implements AsyncEmitter {
options.underscored = true;
}
this.logger.debug(`beforeDefineCollection: ${safeJsonStringify(options)}`);
this.logger.debug(`beforeDefineCollection: ${safeJsonStringify(options)}`, {
databaseInstanceId: this.instanceId,
});
this.emit('beforeDefineCollection', options);