-
Notifications
You must be signed in to change notification settings - Fork 45
feat: support contextFormatter #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -80,7 +80,8 @@ module.exports = { | |||
meta = meta || {}; | |||
let message; | |||
let output; | |||
const formatter = meta.formatter || options.formatter; | |||
let formatter = meta.formatter || options.formatter; | |||
if (meta.ctx && options.contextFormatter) formatter = options.contextFormatter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contextFormatter 没有默认值,如果定义了则用之
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
==========================================
+ Coverage 99.45% 99.45% +<.01%
==========================================
Files 14 14
Lines 368 369 +1
==========================================
+ Hits 366 367 +1
Misses 2 2
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
==========================================
+ Coverage 99.45% 99.45% +<.01%
==========================================
Files 14 14
Lines 368 370 +2
==========================================
+ Hits 366 368 +2
Misses 2 2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README 也补充下
index.d.ts
Outdated
@@ -20,6 +20,7 @@ export interface LoggerOptions { | |||
export interface EggLoggerOptions extends LoggerOptions { | |||
file: string; | |||
formatter?: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatter?: any; | |
formatter?: (meta?: object) => string; |
Co-Authored-By: popomore <sakura9515@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
lib/egg/context_logger.js
Outdated
@@ -44,6 +44,7 @@ class ContextLogger { | |||
const meta = { | |||
formatter: contextFormatter, | |||
paddingMessage: this.paddingMessage, | |||
ctx: this.ctx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要不要 define 为不可枚举的,避免之前的 logger 有 JSON.stringify 的
This comment has been minimized.
This comment has been minimized.
|
Checklist
npm test
passesAffected core subsystem(s)
Description of change
Ref #46 #37