@midwayjs/typeorm 3.9.5 → 3.9.6-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/cli.js CHANGED
File without changes
@@ -57,6 +57,14 @@ OrmConfiguration = __decorate([
57
57
  {
58
58
  default: {
59
59
  typeorm: {},
60
+ midwayLogger: {
61
+ clients: {
62
+ typeormLogger: {
63
+ fileLogName: 'typeorm.log',
64
+ enableError: false,
65
+ },
66
+ },
67
+ },
60
68
  },
61
69
  },
62
70
  ],
@@ -1,9 +1,10 @@
1
- import { DataSourceManager, IMidwayContainer } from '@midwayjs/core';
1
+ import { DataSourceManager, IMidwayContainer, MidwayLoggerService } from '@midwayjs/core';
2
2
  import { DataSource } from 'typeorm';
3
3
  export declare class TypeORMDataSourceManager extends DataSourceManager<DataSource> {
4
4
  typeormConfig: any;
5
5
  applicationContext: IMidwayContainer;
6
6
  baseDir: string;
7
+ loggerService: MidwayLoggerService;
7
8
  init(): Promise<void>;
8
9
  getName(): string;
9
10
  protected createDataSource(config: any, dataSourceName: string): Promise<DataSource>;
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TypeORMDataSourceManager = void 0;
13
13
  const core_1 = require("@midwayjs/core");
14
14
  const typeorm_1 = require("typeorm");
15
+ const logger_1 = require("./logger");
15
16
  let TypeORMDataSourceManager = class TypeORMDataSourceManager extends core_1.DataSourceManager {
16
17
  async init() {
17
18
  await this.initDataSource(this.typeormConfig, this.baseDir);
@@ -23,6 +24,9 @@ let TypeORMDataSourceManager = class TypeORMDataSourceManager extends core_1.Dat
23
24
  if (config['migrations']) {
24
25
  delete config['migrations'];
25
26
  }
27
+ if (!config['logger']) {
28
+ config['logger'] = new logger_1.TypeORMLogger(this.loggerService.getLogger('typeormLogger'));
29
+ }
26
30
  const dataSource = new typeorm_1.DataSource(config);
27
31
  await dataSource.initialize();
28
32
  return dataSource;
@@ -48,6 +52,10 @@ __decorate([
48
52
  (0, core_1.Inject)(),
49
53
  __metadata("design:type", String)
50
54
  ], TypeORMDataSourceManager.prototype, "baseDir", void 0);
55
+ __decorate([
56
+ (0, core_1.Inject)(),
57
+ __metadata("design:type", core_1.MidwayLoggerService)
58
+ ], TypeORMDataSourceManager.prototype, "loggerService", void 0);
51
59
  __decorate([
52
60
  (0, core_1.Init)(),
53
61
  __metadata("design:type", Function),
@@ -0,0 +1,8 @@
1
+ import { FileLogger, Logger, QueryRunner } from 'typeorm';
2
+ export declare class TypeORMLogger extends FileLogger implements Logger {
3
+ readonly typeormLogger: any;
4
+ constructor(typeormLogger: any);
5
+ log(level: 'log' | 'info' | 'warn', message: any, queryRunner?: QueryRunner): void;
6
+ write(strings: string | string[]): void;
7
+ }
8
+ //# sourceMappingURL=logger.d.ts.map
package/dist/logger.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeORMLogger = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ class TypeORMLogger extends typeorm_1.FileLogger {
6
+ constructor(typeormLogger) {
7
+ super(true);
8
+ this.typeormLogger = typeormLogger;
9
+ }
10
+ log(level, message, queryRunner) {
11
+ switch (level) {
12
+ case 'log':
13
+ this.typeormLogger.debug(message);
14
+ break;
15
+ case 'info':
16
+ this.typeormLogger.info(message);
17
+ break;
18
+ case 'warn':
19
+ this.typeormLogger.warn(message);
20
+ break;
21
+ }
22
+ }
23
+ write(strings) {
24
+ this.typeormLogger.info(strings);
25
+ }
26
+ }
27
+ exports.TypeORMLogger = TypeORMLogger;
28
+ //# sourceMappingURL=logger.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/typeorm",
3
- "version": "3.9.5",
3
+ "version": "3.9.6-beta.1",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -34,6 +34,5 @@
34
34
  "repository": {
35
35
  "type": "git",
36
36
  "url": "https://github.com/midwayjs/midway.git"
37
- },
38
- "gitHead": "753614cd3ff5491224d0a78afd31821ab8d60837"
37
+ }
39
38
  }
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.