Skip to content

Commit

Permalink
fix: web logger
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Dec 20, 2024
1 parent e475acd commit 49ddd61
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 300 deletions.
2 changes: 1 addition & 1 deletion packages/web/test/feature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('/test/feature.test.ts', () => {
expect(result.status).toEqual(200);
expect(result.text).toEqual('hello world,harry');
await sleep();
expect(matchContentTimes(join(app.getAppDir(), 'logs', 'ali-demo', 'midway-web.log'), 'GET abcde')).toEqual(4);
expect(matchContentTimes(join(app.getAppDir(), 'logs', 'ali-demo', 'midway-web.log'), 'GET abcde')).toEqual(5);
expect(matchContentTimes(join(app.getAppDir(), 'logs', 'ali-demo', 'midway-web.log'), 'abcde] custom label')).toEqual(1);
await closeApp(app);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ export const midwayFeature = {
}

export const egg = {
contextLoggerFormat: info => {
const ctx = info.ctx;
return `${info.timestamp} ${info.LEVEL} ${info.pid} [${Date.now() - ctx.startTime}ms ${ctx.method} abcde] ${info.message}`;
},
}

export const midwayLogger = {
clients: {
appLogger: {
contextFormat: info => {
const ctx = info.ctx;
return `${info.timestamp} ${info.LEVEL} ${info.pid} [${Date.now() - ctx.startTime}ms ${ctx.method} abcde] ${info.message}`;
},
}
}
}
Loading

0 comments on commit 49ddd61

Please sign in to comment.