@midwayjs/core 3.12.2 → 3.13.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseFramework.d.ts +3 -4
- package/dist/baseFramework.js +2 -2
- package/dist/common/dataSourceManager.d.ts +3 -0
- package/dist/common/dataSourceManager.js +21 -1
- package/dist/common/loggerFactory.d.ts +25 -1
- package/dist/common/loggerFactory.js +26 -1
- package/dist/config/config.default.js +1 -12
- package/dist/index.d.ts +0 -1
- package/dist/interface.d.ts +43 -7
- package/dist/service/configService.d.ts +1 -0
- package/dist/service/configService.js +3 -0
- package/dist/service/loggerService.d.ts +4 -2
- package/dist/service/loggerService.js +29 -2
- package/dist/setup.js +6 -0
- package/package.json +5 -5
- package/LICENSE +0 -21
package/dist/baseFramework.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CommonMiddlewareUnion, IConfigurationOptions, IMidwayApplication, IMidwayBootstrapOptions, IMidwayContainer, IMidwayContext, IMidwayFramework, CommonFilterUnion, MiddlewareRespond, CommonGuardUnion } from './interface';
|
|
2
|
-
import { ILogger, LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
1
|
+
import { CommonMiddlewareUnion, IConfigurationOptions, IMidwayApplication, IMidwayBootstrapOptions, IMidwayContainer, IMidwayContext, IMidwayFramework, CommonFilterUnion, MiddlewareRespond, CommonGuardUnion, ILogger, MidwayLoggerOptions } from './interface';
|
|
3
2
|
import { MidwayEnvironmentService } from './service/environmentService';
|
|
4
3
|
import { MidwayConfigService } from './service/configService';
|
|
5
4
|
import { MidwayInformationService } from './service/informationService';
|
|
@@ -18,7 +17,7 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
18
17
|
protected appLogger: ILogger;
|
|
19
18
|
protected defaultContext: {};
|
|
20
19
|
protected contextLoggerApplyLogger: string;
|
|
21
|
-
protected contextLoggerFormat:
|
|
20
|
+
protected contextLoggerFormat: any;
|
|
22
21
|
protected middlewareManager: ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
23
22
|
protected filterManager: FilterManager<CTX, ResOrNext, Next>;
|
|
24
23
|
protected guardManager: GuardManager<CTX>;
|
|
@@ -80,7 +79,7 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
80
79
|
applyMiddleware<R, N>(lastMiddleware?: CommonMiddlewareUnion<CTX, R, N>): Promise<MiddlewareRespond<CTX, R, N>>;
|
|
81
80
|
getLogger(name?: string): any;
|
|
82
81
|
getCoreLogger(): ILogger;
|
|
83
|
-
createLogger(name: string, option?:
|
|
82
|
+
createLogger(name: string, option?: MidwayLoggerOptions): any;
|
|
84
83
|
getProjectName(): string;
|
|
85
84
|
getFrameworkName(): string;
|
|
86
85
|
useMiddleware(middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
|
package/dist/baseFramework.js
CHANGED
|
@@ -107,7 +107,7 @@ class BaseFramework {
|
|
|
107
107
|
return ctxLoggerCache.get(name);
|
|
108
108
|
}
|
|
109
109
|
// create new context logger
|
|
110
|
-
const ctxLogger =
|
|
110
|
+
const ctxLogger = this.loggerService.createContextLogger(ctx, appLogger, {
|
|
111
111
|
contextFormat: this.contextLoggerFormat,
|
|
112
112
|
});
|
|
113
113
|
ctxLoggerCache.set(name, ctxLogger);
|
|
@@ -118,7 +118,7 @@ class BaseFramework {
|
|
|
118
118
|
if (ctx['_logger']) {
|
|
119
119
|
return ctx['_logger'];
|
|
120
120
|
}
|
|
121
|
-
ctx['_logger'] =
|
|
121
|
+
ctx['_logger'] = this.loggerService.createContextLogger(ctx, appLogger, {
|
|
122
122
|
contextFormat: this.contextLoggerFormat,
|
|
123
123
|
});
|
|
124
124
|
return ctx['_logger'];
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ModuleLoadType, DataSourceManagerConfigOption } from '../interface';
|
|
2
|
+
import { MidwayEnvironmentService } from '../service/environmentService';
|
|
2
3
|
export declare abstract class DataSourceManager<T, ConnectionOpts extends Record<string, any> = Record<string, any>> {
|
|
3
4
|
protected dataSource: Map<string, T>;
|
|
4
5
|
protected options: DataSourceManagerConfigOption<ConnectionOpts>;
|
|
5
6
|
protected modelMapping: WeakMap<object, any>;
|
|
6
7
|
private innerDefaultDataSourceName;
|
|
8
|
+
appDir: string;
|
|
9
|
+
environmentService: MidwayEnvironmentService;
|
|
7
10
|
protected initDataSource(dataSourceConfig: DataSourceManagerConfigOption<ConnectionOpts>, baseDirOrOptions: {
|
|
8
11
|
baseDir: string;
|
|
9
12
|
entitiesConfigKey?: string;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.globModels = exports.formatGlobString = exports.DataSourceManager = void 0;
|
|
4
13
|
/**
|
|
@@ -12,6 +21,8 @@ const types_1 = require("../util/types");
|
|
|
12
21
|
const constants_1 = require("../constants");
|
|
13
22
|
const util_1 = require("util");
|
|
14
23
|
const util_2 = require("../util");
|
|
24
|
+
const decorator_1 = require("../decorator");
|
|
25
|
+
const environmentService_1 = require("../service/environmentService");
|
|
15
26
|
const debug = (0, util_1.debuglog)('midway:debug');
|
|
16
27
|
class DataSourceManager {
|
|
17
28
|
constructor() {
|
|
@@ -20,6 +31,7 @@ class DataSourceManager {
|
|
|
20
31
|
this.modelMapping = new WeakMap();
|
|
21
32
|
}
|
|
22
33
|
async initDataSource(dataSourceConfig, baseDirOrOptions) {
|
|
34
|
+
var _a;
|
|
23
35
|
this.options = dataSourceConfig;
|
|
24
36
|
if (!this.options.dataSource) {
|
|
25
37
|
throw new error_1.MidwayParameterError('[DataSourceManager] must set options.dataSource.');
|
|
@@ -39,7 +51,7 @@ class DataSourceManager {
|
|
|
39
51
|
for (const entity of userEntities) {
|
|
40
52
|
if (typeof entity === 'string') {
|
|
41
53
|
// string will be glob file
|
|
42
|
-
const models = await globModels(entity, baseDirOrOptions.baseDir);
|
|
54
|
+
const models = await globModels(entity, baseDirOrOptions.baseDir, (_a = this.environmentService) === null || _a === void 0 ? void 0 : _a.getModuleLoadType());
|
|
43
55
|
for (const model of models) {
|
|
44
56
|
entities.add(model);
|
|
45
57
|
this.modelMapping.set(model, dataSourceName);
|
|
@@ -141,6 +153,14 @@ class DataSourceManager {
|
|
|
141
153
|
return this.innerDefaultDataSourceName;
|
|
142
154
|
}
|
|
143
155
|
}
|
|
156
|
+
__decorate([
|
|
157
|
+
(0, decorator_1.Inject)(),
|
|
158
|
+
__metadata("design:type", String)
|
|
159
|
+
], DataSourceManager.prototype, "appDir", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, decorator_1.Inject)(),
|
|
162
|
+
__metadata("design:type", environmentService_1.MidwayEnvironmentService)
|
|
163
|
+
], DataSourceManager.prototype, "environmentService", void 0);
|
|
144
164
|
exports.DataSourceManager = DataSourceManager;
|
|
145
165
|
function formatGlobString(globString) {
|
|
146
166
|
let pattern;
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import { ILogger } from '../interface';
|
|
1
|
+
import { ILogger, MidwayAppInfo } from '../interface';
|
|
2
2
|
export declare abstract class LoggerFactory<Logger extends ILogger, LoggerOptions> {
|
|
3
3
|
abstract createLogger(name: string, options: LoggerOptions): Logger;
|
|
4
4
|
abstract getLogger(loggerName: string): Logger;
|
|
5
5
|
abstract close(loggerName?: string): any;
|
|
6
6
|
abstract removeLogger(loggerName: string): any;
|
|
7
|
+
abstract getDefaultMidwayLoggerConfig(appInfo: MidwayAppInfo): {
|
|
8
|
+
midwayLogger: {
|
|
9
|
+
default?: LoggerOptions;
|
|
10
|
+
clients?: {
|
|
11
|
+
[loggerName: string]: LoggerOptions;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
abstract createContextLogger(ctx: any, appLogger: ILogger, contextOptions?: any): ILogger;
|
|
16
|
+
}
|
|
17
|
+
export declare class DefaultConsoleLoggerFactory implements LoggerFactory<ILogger, any> {
|
|
18
|
+
createLogger(name: string, options: any): ILogger;
|
|
19
|
+
getLogger(loggerName: string): ILogger;
|
|
20
|
+
close(loggerName?: string): void;
|
|
21
|
+
removeLogger(loggerName: string): void;
|
|
22
|
+
getDefaultMidwayLoggerConfig(): {
|
|
23
|
+
midwayLogger: {
|
|
24
|
+
default?: any;
|
|
25
|
+
clients?: {
|
|
26
|
+
[p: string]: any;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
createContextLogger(ctx: any, appLogger: ILogger): ILogger;
|
|
7
31
|
}
|
|
8
32
|
//# sourceMappingURL=loggerFactory.d.ts.map
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerFactory = void 0;
|
|
3
|
+
exports.DefaultConsoleLoggerFactory = exports.LoggerFactory = void 0;
|
|
4
4
|
class LoggerFactory {
|
|
5
5
|
}
|
|
6
6
|
exports.LoggerFactory = LoggerFactory;
|
|
7
|
+
class DefaultConsoleLoggerFactory {
|
|
8
|
+
createLogger(name, options) {
|
|
9
|
+
return console;
|
|
10
|
+
}
|
|
11
|
+
getLogger(loggerName) {
|
|
12
|
+
return console;
|
|
13
|
+
}
|
|
14
|
+
close(loggerName) { }
|
|
15
|
+
removeLogger(loggerName) { }
|
|
16
|
+
getDefaultMidwayLoggerConfig() {
|
|
17
|
+
return {
|
|
18
|
+
midwayLogger: {
|
|
19
|
+
default: {},
|
|
20
|
+
clients: {
|
|
21
|
+
coreLogger: {},
|
|
22
|
+
appLogger: {},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
createContextLogger(ctx, appLogger) {
|
|
28
|
+
return appLogger;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DefaultConsoleLoggerFactory = DefaultConsoleLoggerFactory;
|
|
7
32
|
//# sourceMappingURL=loggerFactory.js.map
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const util_1 = require("../util/");
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
4
|
exports.default = (appInfo) => {
|
|
7
|
-
var _a;
|
|
8
5
|
const isDevelopment = (0, util_1.isDevelopmentEnvironment)((0, util_1.getCurrentEnvironment)());
|
|
9
|
-
const logRoot = (_a = process.env[constants_1.MIDWAY_LOGGER_WRITEABLE_DIR]) !== null && _a !== void 0 ? _a : appInfo.root;
|
|
10
6
|
return {
|
|
11
7
|
asyncContextManager: {
|
|
12
8
|
enable: false,
|
|
13
9
|
},
|
|
14
10
|
midwayLogger: {
|
|
15
11
|
default: {
|
|
16
|
-
dir: (0, path_1.join)(logRoot, 'logs', appInfo.name),
|
|
17
12
|
level: 'info',
|
|
18
|
-
consoleLevel: isDevelopment ? 'info' : 'warn',
|
|
19
|
-
auditFileDir: '.audit',
|
|
20
13
|
},
|
|
21
14
|
clients: {
|
|
22
|
-
coreLogger: {
|
|
23
|
-
level: isDevelopment ? 'info' : 'warn',
|
|
24
|
-
fileLogName: 'midway-core.log',
|
|
25
|
-
},
|
|
15
|
+
coreLogger: {},
|
|
26
16
|
appLogger: {
|
|
27
|
-
fileLogName: 'midway-app.log',
|
|
28
17
|
aliasName: 'logger',
|
|
29
18
|
},
|
|
30
19
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -45,5 +45,4 @@ export { Types } from './util/types';
|
|
|
45
45
|
export { PathFileUtil } from './util/pathFileUtil';
|
|
46
46
|
export { FileUtils } from './util/fs';
|
|
47
47
|
export { FORMAT } from './util/format';
|
|
48
|
-
export type { ILogger, IMidwayLogger } from '@midwayjs/logger';
|
|
49
48
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
3
2
|
import * as EventEmitter from 'events';
|
|
4
3
|
import type { AsyncContextManager } from './common/asyncContextManager';
|
|
5
4
|
import type { LoggerFactory } from './common/loggerFactory';
|
|
@@ -343,16 +342,53 @@ export interface ParamDecoratorOptions {
|
|
|
343
342
|
throwError?: boolean;
|
|
344
343
|
pipes?: PipeUnionTransform<any, any>[];
|
|
345
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Logger Options for midway, you can merge this interface in package
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
*
|
|
350
|
+
* import { IMidwayLogger } from '@midwayjs/logger';
|
|
351
|
+
*
|
|
352
|
+
* declare module '@midwayjs/core/dist/interface' {
|
|
353
|
+
* interface ILogger extends IMidwayLogger {
|
|
354
|
+
* }
|
|
355
|
+
* }
|
|
356
|
+
*
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
346
359
|
export interface ILogger {
|
|
347
360
|
info(msg: any, ...args: any[]): void;
|
|
348
361
|
debug(msg: any, ...args: any[]): void;
|
|
349
362
|
error(msg: any, ...args: any[]): void;
|
|
350
363
|
warn(msg: any, ...args: any[]): void;
|
|
351
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* @deprecated
|
|
367
|
+
*/
|
|
368
|
+
export type IMidwayLogger = ILogger;
|
|
369
|
+
/**
|
|
370
|
+
* Logger Options for midway, you can merge this interface in package
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
*
|
|
374
|
+
* import { LoggerOptions } from '@midwayjs/logger';
|
|
375
|
+
*
|
|
376
|
+
* declare module '@midwayjs/core/dist/interface' {
|
|
377
|
+
* interface MidwayLoggerOptions extends LoggerOptions {
|
|
378
|
+
* logDir?: string;
|
|
379
|
+
* level?: string;
|
|
380
|
+
* }
|
|
381
|
+
* }
|
|
382
|
+
*
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
export interface MidwayLoggerOptions {
|
|
386
|
+
lazyLoad?: boolean;
|
|
387
|
+
aliasName?: string;
|
|
388
|
+
[key: string]: any;
|
|
389
|
+
}
|
|
352
390
|
export interface MidwayCoreDefaultConfig {
|
|
353
|
-
midwayLogger?: ServiceFactoryConfigOption<
|
|
354
|
-
lazyLoad?: boolean;
|
|
355
|
-
}>;
|
|
391
|
+
midwayLogger?: ServiceFactoryConfigOption<MidwayLoggerOptions>;
|
|
356
392
|
debug?: {
|
|
357
393
|
recordConfigMergeOrder?: boolean;
|
|
358
394
|
};
|
|
@@ -762,7 +798,7 @@ export interface IMidwayBaseApplication<CTX extends IMidwayContext> {
|
|
|
762
798
|
* @param name
|
|
763
799
|
* @param options
|
|
764
800
|
*/
|
|
765
|
-
createLogger(name: string, options:
|
|
801
|
+
createLogger(name: string, options: MidwayLoggerOptions): ILogger;
|
|
766
802
|
/**
|
|
767
803
|
* Get project name, just package.json name
|
|
768
804
|
*/
|
|
@@ -847,7 +883,7 @@ export interface IConfigurationOptions {
|
|
|
847
883
|
logger?: ILogger;
|
|
848
884
|
appLogger?: ILogger;
|
|
849
885
|
contextLoggerApplyLogger?: string;
|
|
850
|
-
contextLoggerFormat?:
|
|
886
|
+
contextLoggerFormat?: any;
|
|
851
887
|
}
|
|
852
888
|
export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX extends IMidwayContext, CONFIG extends IConfigurationOptions, ResOrNext = unknown, Next = unknown> {
|
|
853
889
|
app: APP;
|
|
@@ -866,7 +902,7 @@ export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX exten
|
|
|
866
902
|
getBaseDir(): string;
|
|
867
903
|
getLogger(name?: string): ILogger;
|
|
868
904
|
getCoreLogger(): ILogger;
|
|
869
|
-
createLogger(name: string, options:
|
|
905
|
+
createLogger(name: string, options: MidwayLoggerOptions): ILogger;
|
|
870
906
|
getProjectName(): string;
|
|
871
907
|
useMiddleware(Middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
|
|
872
908
|
getMiddleware(): IMiddlewareManager<CTX, ResOrNext, Next>;
|
|
@@ -34,6 +34,7 @@ export declare class MidwayConfigService implements IConfigService {
|
|
|
34
34
|
*/
|
|
35
35
|
addFilter(filter: (config: Record<string, any>) => Record<string, any>): void;
|
|
36
36
|
protected runWithFilter(config: Record<string, any>): Record<string, any>;
|
|
37
|
+
getAppInfo(): MidwayAppInfo;
|
|
37
38
|
}
|
|
38
39
|
export {};
|
|
39
40
|
//# sourceMappingURL=configService.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MidwayConfigService } from './configService';
|
|
2
2
|
import { ServiceFactory } from '../common/serviceFactory';
|
|
3
|
-
import { ILogger, IMidwayContainer } from '../interface';
|
|
3
|
+
import { ILogger, IMidwayContainer, IMidwayContext, MidwayLoggerOptions } from '../interface';
|
|
4
4
|
import { LoggerFactory } from '../common/loggerFactory';
|
|
5
5
|
export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
|
|
6
6
|
readonly applicationContext: IMidwayContainer;
|
|
@@ -8,12 +8,14 @@ export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
|
|
|
8
8
|
configService: MidwayConfigService;
|
|
9
9
|
private loggerFactory;
|
|
10
10
|
private lazyLoggerConfigMap;
|
|
11
|
+
private aliasLoggerMap;
|
|
11
12
|
constructor(applicationContext: IMidwayContainer, globalOptions?: {});
|
|
12
13
|
protected init(): void;
|
|
13
14
|
protected createClient(config: any, name?: string): void;
|
|
14
15
|
getName(): string;
|
|
15
|
-
createLogger(name:
|
|
16
|
+
createLogger(name: string, config: MidwayLoggerOptions): any;
|
|
16
17
|
getLogger(name: string): any;
|
|
17
18
|
getCurrentLoggerFactory(): LoggerFactory<any, any>;
|
|
19
|
+
createContextLogger(ctx: IMidwayContext, appLogger: ILogger, contextOptions?: any): ILogger;
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=loggerService.d.ts.map
|
|
@@ -14,22 +14,41 @@ const decorator_1 = require("../decorator");
|
|
|
14
14
|
const configService_1 = require("./configService");
|
|
15
15
|
const serviceFactory_1 = require("../common/serviceFactory");
|
|
16
16
|
const interface_1 = require("../interface");
|
|
17
|
-
const
|
|
17
|
+
const loggerFactory_1 = require("../common/loggerFactory");
|
|
18
|
+
const error_1 = require("../error");
|
|
18
19
|
let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.ServiceFactory {
|
|
19
20
|
constructor(applicationContext, globalOptions = {}) {
|
|
20
21
|
super();
|
|
21
22
|
this.applicationContext = applicationContext;
|
|
22
23
|
this.globalOptions = globalOptions;
|
|
23
24
|
this.lazyLoggerConfigMap = new Map();
|
|
25
|
+
this.aliasLoggerMap = new Map();
|
|
24
26
|
}
|
|
25
27
|
init() {
|
|
26
28
|
var _a;
|
|
27
|
-
|
|
29
|
+
const loggerFactory = this.configService.getConfiguration('loggerFactory');
|
|
30
|
+
// load logger factory from user config first
|
|
31
|
+
this.loggerFactory =
|
|
32
|
+
loggerFactory ||
|
|
33
|
+
this.globalOptions['loggerFactory'] ||
|
|
34
|
+
new loggerFactory_1.DefaultConsoleLoggerFactory();
|
|
35
|
+
// check
|
|
36
|
+
if (!this.loggerFactory.getDefaultMidwayLoggerConfig) {
|
|
37
|
+
throw new error_1.MidwayFeatureNoLongerSupportedError('please upgrade your @midwayjs/logger to latest version');
|
|
38
|
+
}
|
|
39
|
+
const defaultLoggerConfig = this.loggerFactory.getDefaultMidwayLoggerConfig(this.configService.getAppInfo());
|
|
40
|
+
// merge to user config
|
|
41
|
+
this.configService.addObject(defaultLoggerConfig, true);
|
|
42
|
+
// init logger
|
|
28
43
|
this.initClients(this.configService.getConfiguration('midwayLogger'));
|
|
29
44
|
// alias inject logger
|
|
30
45
|
(_a = this.applicationContext) === null || _a === void 0 ? void 0 : _a.registerObject('logger', this.getLogger('appLogger'));
|
|
31
46
|
}
|
|
32
47
|
createClient(config, name) {
|
|
48
|
+
if (config.aliasName) {
|
|
49
|
+
// mapping alias logger name to real logger name
|
|
50
|
+
this.aliasLoggerMap.set(config.aliasName, name);
|
|
51
|
+
}
|
|
33
52
|
if (!config.lazyLoad) {
|
|
34
53
|
this.loggerFactory.createLogger(name, config);
|
|
35
54
|
}
|
|
@@ -42,9 +61,14 @@ let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.Ser
|
|
|
42
61
|
return 'logger';
|
|
43
62
|
}
|
|
44
63
|
createLogger(name, config) {
|
|
64
|
+
delete config['aliasName'];
|
|
45
65
|
return this.loggerFactory.createLogger(name, config);
|
|
46
66
|
}
|
|
47
67
|
getLogger(name) {
|
|
68
|
+
if (this.aliasLoggerMap.has(name)) {
|
|
69
|
+
// get real logger name
|
|
70
|
+
name = this.aliasLoggerMap.get(name);
|
|
71
|
+
}
|
|
48
72
|
const logger = this.loggerFactory.getLogger(name);
|
|
49
73
|
if (logger) {
|
|
50
74
|
return logger;
|
|
@@ -59,6 +83,9 @@ let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.Ser
|
|
|
59
83
|
getCurrentLoggerFactory() {
|
|
60
84
|
return this.loggerFactory;
|
|
61
85
|
}
|
|
86
|
+
createContextLogger(ctx, appLogger, contextOptions) {
|
|
87
|
+
return this.loggerFactory.createContextLogger(ctx, appLogger, contextOptions);
|
|
88
|
+
}
|
|
62
89
|
};
|
|
63
90
|
__decorate([
|
|
64
91
|
(0, decorator_1.Inject)(),
|
package/dist/setup.js
CHANGED
|
@@ -142,6 +142,9 @@ async function prepareGlobalApplicationContextAsync(globalOptions) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
printStepDebugInfo('Init MidwayConfigService, MidwayAspectService and MidwayDecoratorService');
|
|
145
|
+
// init default environment
|
|
146
|
+
const environmentService = applicationContext.get(_1.MidwayEnvironmentService);
|
|
147
|
+
environmentService.setModuleLoadType(globalOptions.moduleLoadType);
|
|
145
148
|
// init default config
|
|
146
149
|
const configService = applicationContext.get(_1.MidwayConfigService);
|
|
147
150
|
configService.add([
|
|
@@ -196,6 +199,9 @@ function prepareGlobalApplicationContext(globalOptions) {
|
|
|
196
199
|
applicationContext.registerObject('baseDir', baseDir);
|
|
197
200
|
applicationContext.registerObject('appDir', appDir);
|
|
198
201
|
printStepDebugInfo('Ready module detector');
|
|
202
|
+
if (!globalOptions.moduleLoadType) {
|
|
203
|
+
globalOptions.moduleLoadType = 'commonjs';
|
|
204
|
+
}
|
|
199
205
|
if (globalOptions.moduleDetector !== false) {
|
|
200
206
|
if (globalOptions.moduleDetector === undefined) {
|
|
201
207
|
applicationContext.setFileDetector(new _1.CommonJSFileDetector({
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0-beta.1",
|
|
4
4
|
"description": "midway core",
|
|
5
|
-
"main": "dist/index",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"koa": "2.14.1",
|
|
26
26
|
"mm": "3.3.0",
|
|
27
27
|
"raw-body": "2.5.2",
|
|
28
|
-
"sinon": "15.2.0"
|
|
28
|
+
"sinon": "15.2.0",
|
|
29
|
+
"@midwayjs/logger": "3.0.0"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@midwayjs/glob": "^1.0.2",
|
|
32
|
-
"@midwayjs/logger": "^2.15.0",
|
|
33
33
|
"class-transformer": "0.5.1",
|
|
34
34
|
"picomatch": "2.3.1",
|
|
35
35
|
"reflect-metadata": "0.1.13"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=12"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a603d2348d6141f8f723901498f03a162a037708"
|
|
46
46
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|