mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
53e3f3595c
@ -22,6 +22,7 @@ export abstract class DataSource extends EventEmitter {
|
||||
public resourceManager: ResourceManager;
|
||||
public acl: ACL;
|
||||
logger: Logger;
|
||||
_sqlLogger: Logger;
|
||||
|
||||
constructor(protected options: DataSourceOptions) {
|
||||
super();
|
||||
@ -32,6 +33,14 @@ export abstract class DataSource extends EventEmitter {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
setSqlLogger(logger: Logger) {
|
||||
this._sqlLogger = logger;
|
||||
}
|
||||
|
||||
get sqlLogger() {
|
||||
return this._sqlLogger || this.logger;
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.options.name;
|
||||
}
|
||||
|
@ -225,7 +225,6 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
private _maintainingCommandStatus: MaintainingCommandStatus;
|
||||
private _maintainingStatusBeforeCommand: MaintainingCommandStatus | null;
|
||||
private _actionCommand: Command;
|
||||
private sqlLogger: Logger;
|
||||
|
||||
constructor(public options: ApplicationOptions) {
|
||||
super();
|
||||
@ -238,6 +237,18 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
}
|
||||
}
|
||||
|
||||
private _sqlLogger: Logger;
|
||||
|
||||
get sqlLogger() {
|
||||
return this._sqlLogger;
|
||||
}
|
||||
|
||||
protected _logger: SystemLogger;
|
||||
|
||||
get logger() {
|
||||
return this._logger;
|
||||
}
|
||||
|
||||
protected _started: Date | null = null;
|
||||
|
||||
/**
|
||||
@ -247,12 +258,6 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
return this._started;
|
||||
}
|
||||
|
||||
protected _logger: SystemLogger;
|
||||
|
||||
get logger() {
|
||||
return this._logger;
|
||||
}
|
||||
|
||||
get log() {
|
||||
return this._logger;
|
||||
}
|
||||
@ -1084,12 +1089,14 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
// Due to the use of custom log levels,
|
||||
// we have to use any type here until Winston updates the type definitions.
|
||||
}) as any;
|
||||
|
||||
this.requestLogger = createLogger({
|
||||
dirname: getLoggerFilePath(this.name),
|
||||
filename: 'request',
|
||||
...(options?.request || {}),
|
||||
});
|
||||
this.sqlLogger = this.createLogger({
|
||||
|
||||
this._sqlLogger = this.createLogger({
|
||||
filename: 'sql',
|
||||
level: 'debug',
|
||||
});
|
||||
@ -1098,7 +1105,7 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
protected closeLogger() {
|
||||
this.log?.close();
|
||||
this.requestLogger?.close();
|
||||
this.sqlLogger?.close();
|
||||
this._sqlLogger?.close();
|
||||
}
|
||||
|
||||
protected init() {
|
||||
@ -1210,7 +1217,7 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
if (msg.includes('INSERT INTO')) {
|
||||
msg = msg.substring(0, 2000) + '...';
|
||||
}
|
||||
this.sqlLogger.debug({ message: msg, app: this.name, reqId: this.context.reqId });
|
||||
this._sqlLogger.debug({ message: msg, app: this.name, reqId: this.context.reqId });
|
||||
};
|
||||
const dbOptions = options.database instanceof Database ? options.database.options : options.database;
|
||||
const db = new Database({
|
||||
|
@ -96,6 +96,7 @@ export class DataSourceModel extends Model {
|
||||
...createOptions,
|
||||
name: dataSourceKey,
|
||||
logger: app.logger.child({ dataSourceKey }),
|
||||
sqlLogger: app.sqlLogger.child({ dataSourceKey }),
|
||||
});
|
||||
|
||||
if (loadAtAfterStart) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user