-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable coreLogger info console output in local env (#829)
- Loading branch information
1 parent
7941f87
commit adaaaea
Showing
12 changed files
with
107 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/web/test/fixtures/feature/base-app-set-ctx-logger/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "ali-demo" | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/web/test/fixtures/feature/base-app-set-ctx-logger/src/config/config.default.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
export const keys = 'key'; | ||
|
||
export const hello = { | ||
a: 1, | ||
b: 2, | ||
d: [1, 2, 3], | ||
}; | ||
|
||
export const midwayFeature = { | ||
replaceEggLogger: true, | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/web/test/fixtures/feature/base-app-set-ctx-logger/src/config/config.unittest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
exports.hello = { | ||
b: 4, | ||
c: 3, | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/web/test/fixtures/feature/base-app-set-ctx-logger/src/configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Configuration, App } from '@midwayjs/decorator'; | ||
import { MidwayCustomContextLogger } from './logger'; | ||
|
||
@Configuration({ | ||
importConfigs: [ | ||
'./config' | ||
] | ||
}) | ||
export class ContainerConfiguration { | ||
@App() | ||
app: any; | ||
|
||
async onReady() { | ||
this.app.setContextLoggerClass(MidwayCustomContextLogger); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/web/test/fixtures/feature/base-app-set-ctx-logger/src/controller/api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
Controller, | ||
Get, | ||
Provide, | ||
Inject, | ||
Query, | ||
} from '@midwayjs/decorator'; | ||
|
||
@Provide() | ||
@Controller('/') | ||
export class APIController { | ||
@Inject() | ||
ctx: any; | ||
|
||
@Get('/') | ||
async home(@Query('name') name: string) { | ||
this.ctx.logger.info('custom label'); | ||
return 'hello world,' + name; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/web/test/fixtures/feature/base-app-set-ctx-logger/src/logger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { MidwayContextLogger } from '@midwayjs/core'; | ||
import { Context } from 'egg'; | ||
|
||
export class MidwayCustomContextLogger extends MidwayContextLogger<Context> { | ||
formatContextLabel() { | ||
const ctx = this.ctx; | ||
return `${Date.now() - ctx.startTime}ms ${ctx.method}`; | ||
} | ||
} |