-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: BaseContextClass add logger #816
Conversation
- move BaseContextClass to egg - add BaseContextLogger
@dead-horse, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fengmk2, @popomore and @shaoshuai0102 to be potential reviewers. |
lib/core/base_context_class.js
Outdated
* @param {String} pathName - class path name | ||
* @since 1.0.0 | ||
*/ | ||
constructor(ctx, pathName) { |
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.
pathName 只是在 Controller 用的?
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.
service 和 controller 都用了,这里还是去掉了,靠 egg-core 注入吧,本来想改成显示声明的,不过对 egg-core 的改动有点大,先算了。
@popomore 还是讲 base-context-class 移到 egg 里面维护吧,egg-core 没有 logger 对象挺蛋疼的 |
egg-core 里面的先保留,保证兼容 |
egg 继承一个吧,这里面 helper 要用。 |
Codecov Report
@@ Coverage Diff @@
## master #816 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 25 27 +2
Lines 641 666 +25
=====================================
+ Hits 641 666 +25
Continue to review full report at Codecov.
|
@@ -77,6 +77,7 @@ module.exports = app => { | |||
- `this.app`: 当前应用 [Application](./extend.md#application) 对象的实例,通过它我们可以拿到框架提供的全局对象和方法。 | |||
- `this.service`:应用定义的 [Service](./service.md),通过它我们可以访问到抽象出的业务层,等价于 `this.ctx.service` 。 | |||
- `this.config`:应用运行时的[配置项](./config.md)。 | |||
- `this.logger`:logger 对象,上面有四个方法(DEBUG,INFO,WARN,ERROR),分别代表打印四个不同级别的日志,使用方法和效果与[context logger](../core/logger.md#context-logger)中介绍的一样,但是通过这个 logger 对象记录的日志,在日志前面会加上打印该日志的文件路径,以便快速定位日志打印位置。 |
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.
方法不是大写的吧
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.
[context logger]
前后空格
看了一下 egg-core 里面没有依赖 BaseContextClass,测 controller loader 也不需要使用这个基类,任意一个 class 就可以了,还是放到 egg 里面来维护吧。 测试有点诡异,本地正常, CI 上跑有一个 case 一直超时。 |
今天好几个库的 ci 都有超时 |
终于都过了 |
@popomore 这个合了之后发个新版本吧 |
Checklist
npm test
passesAffected core subsystem(s)
BaseContextClass
Description of change