mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-11-29 18:58:26 +08:00
chore: data source logger instance (#4181)
This commit is contained in:
parent
2dc9622acc
commit
7849bbd889
@ -1,5 +1,5 @@
|
||||
import winston, { Logger, format } from 'winston';
|
||||
import { LoggerOptions, createLogger } from './logger';
|
||||
import winston, { format, Logger } from 'winston';
|
||||
import { createLogger, LoggerOptions } from './logger';
|
||||
import Transport from 'winston-transport';
|
||||
import { SPLAT } from 'triple-beam';
|
||||
import { getFormat } from './format';
|
||||
@ -49,7 +49,7 @@ class SystemLoggerTransport extends Transport {
|
||||
}
|
||||
|
||||
log(info: any, callback: any) {
|
||||
const { level, message, reqId, app, stack, cause, [SPLAT]: args } = info;
|
||||
const { level, message, reqId, app, dataSourceKey, stack, cause, [SPLAT]: args } = info;
|
||||
const logger = level === 'error' && this.errorLogger ? this.errorLogger : this.logger;
|
||||
const { module, submodule, method, ...meta } = args?.[0] || {};
|
||||
logger.log({
|
||||
@ -62,6 +62,7 @@ class SystemLoggerTransport extends Transport {
|
||||
method: method || '',
|
||||
app,
|
||||
reqId,
|
||||
dataSourceKey: dataSourceKey || 'main',
|
||||
});
|
||||
if (cause) {
|
||||
logger.log({
|
||||
|
@ -90,7 +90,8 @@ export class DataSourceModel extends Model {
|
||||
|
||||
const dataSource = app.dataSourceManager.factory.create(type, {
|
||||
...createOptions,
|
||||
name: this.get('key'),
|
||||
name: dataSourceKey,
|
||||
logger: app.logger.child({ dataSourceKey }),
|
||||
});
|
||||
|
||||
if (loadAtAfterStart) {
|
||||
|
Loading…
Reference in New Issue
Block a user