Open
Conversation
Codecov Report
@@ Coverage Diff @@
## master #63 +/- ##
==========================================
+ Coverage 45.73% 46.83% +1.10%
==========================================
Files 48 48
Lines 2683 2797 +114
==========================================
+ Hits 1227 1310 +83
- Misses 1374 1394 +20
- Partials 82 93 +11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Contributor
|
add testcase |
taoyuanyuan
reviewed
Jun 30, 2022
0d885dd to
e8596e9
Compare
nejisama
reviewed
Aug 5, 2022
doujiang24
reviewed
Aug 5, 2022
nejisama
reviewed
Aug 5, 2022
nejisama
reviewed
Aug 5, 2022
ca00f87 to
6410a02
Compare
nejisama
reviewed
Aug 10, 2022
Bryce-huang
reviewed
Aug 12, 2022
doujiang24
reviewed
Aug 25, 2022
nejisama
reviewed
Sep 30, 2022
| } | ||
|
|
||
| func (l *Logger) mill() { | ||
| if l.roller.MaxBackups != defaultRotateKeep || l.roller.MaxAge != defaultRotateAge || l.roller.Compress { |
Collaborator
There was a problem hiding this comment.
这个判断套件不太对啊。
如果配置成和default 一样的值就不执行,这个行为应该是不对的。
为了保持之前默认不执行的逻辑,是不是新加一个开关比较合适。
nejisama
reviewed
Sep 30, 2022
| close(l.stopRotate) | ||
| } | ||
|
|
||
| func TestLogRollerTimeAndCompress(t *testing.T) { |
Collaborator
There was a problem hiding this comment.
测试应该覆盖如下场景:
- 配置按时间轮转,Compress与MaxBackup(比如1),那么至少应该有3个文件,第一个文件正常写,第二个文件写的时候,第一个被轮转,第三个写的时候第二个被轮转,第一个被压缩
- 同样的情况,没有配置Compress,那第一个应该是被删除
- 配置按照大小轮转,其他同1)和2)
| l.create = time.Now() | ||
| } | ||
| l.writer = file | ||
| l.mill() |
Collaborator
There was a problem hiding this comment.
这里执行mill ,看上去可能会有一些耗时。在这期间这个logger实际上是没有办法正常工作的(后面的l.handler没有执行)。如果这里mill 卡太久,可能会导致日志丢失等情况出现,这是需要考虑的风险。
是否可以考虑将这个mill 做成异步的,可以按照日志路径有锁避免并发冲突?但是不影响start的时候及时可以执行写新日志,可以讨论一下
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.