Skip to content

Commit

Permalink
fix: fix debugger logger create in every request (#648)
Browse files Browse the repository at this point in the history
* fix: fix debugger logger create in every request

* fix: use util.debug replace debug
  • Loading branch information
czy88840616 authored Sep 27, 2020
1 parent 602da29 commit 8e70fb0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@midwayjs/decorator": "^2.3.0",
"@midwayjs/glob": "^1.0.2",
"class-transformer": "^0.3.1",
"debug": "^4.1.1",
"extend2": "^1.0.0",
"lodash.assign": "^4.2.0",
"lodash.clonedeep": "^4.5.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/context/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import {
} from '../interface';
import { isPath, safeRequire, generateProvideId } from '../common/util';
import { isClass, isFunction } from '../util';
import * as util from 'util';

const debug = require('debug')('midway:container:configuration');
const debug = util.debuglog('midway:container:configuration');

export class ContainerConfiguration implements IContainerConfiguration {
container: IMidwayContainer;
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/context/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import { FunctionDefinition } from '../definitions/functionDefinition';
import { BaseApplicationContext } from './applicationContext';
import { recursiveGetMetadata } from '../common/reflectTool';
import { generateProvideId } from '../common/util';

import { isAsyncFunction, isClass, isFunction } from '../util';
import * as util from 'util';

const globalDebugLogger = util.debuglog(`midway:container`);

export class Container extends BaseApplicationContext implements IContainer {
id = Math.random().toString(10).slice(-5);
debugLogger = require('debug')(`midway:container:${this.id}`);
debugLogger = globalDebugLogger;
// 自己内部实现的,可注入的 feature(见 features)
protected midwayIdentifiers: string[] = [];
bind<T>(target: T, options?: ObjectDefinitionOptions): void;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/context/managedResolverFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import {
} from '../interface';
import { ObjectProperties } from '../definitions/properties';
import { NotFoundError } from '../common/notFoundError';
import * as util from 'util';

const debug = require('debug')('midway:managedresolver');
const debug = util.debuglog('midway:managedresolver');

/**
* 所有解析器基类
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/context/resolverHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {
import { ManagedResolverFactory } from './managedResolverFactory';
import { MidwayContainer } from './midwayContainer';
import { MIDWAY_ALL_CONFIG } from '../common/constants';
import * as util from 'util';

interface FrameworkDecoratorMetadata {
key: string;
propertyName: string;
}

const debug = require('debug')('midway:container');
const debug = util.debuglog('midway:container');

export type HandlerFunction = (handlerKey: string, instance?: any) => any;

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/service/configService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { IConfigService, IMidwayContainer } from '../interface';
import { safelyGet } from '..';
import { readdirSync, statSync } from 'fs';
import { isFunction } from '../util';
import * as util from 'util';

const debug = require('debug')('midway:config');
const debug = util.debuglog('midway:config');

export class MidwayConfigService implements IConfigService {
envDirMap: Map<string, Set<string>>;
Expand Down

0 comments on commit 8e70fb0

Please sign in to comment.