Skip to content
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

1.修改日志滚动策略逻辑: #529

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

miaomiaoLmm
Copy link

@miaomiaoLmm miaomiaoLmm commented Jul 4, 2024

1.1: TimedRollingFileAppender新增方法 resetTimedRollingFilleConfig(String datePattern),可根据日志滚动策略对日志进行动态配置
1.2: LoadTestAwareAppender 新增rest方法,根据日期策略重置nonLoadTestTraceAppender和loadTestTraceAppender

Motivation:

Explain the context, and why you're making that change.
To make others understand what is the problem you're trying to solve.

Modification:

Describe the idea and modifications you've done.

Result:

Fixes #.

If there is no issue then describe the changes introduced by this PR.

Summary by CodeRabbit

  • Refactor
    • Improved internal logging mechanism to utilize updated file appender configurations, enhancing performance for both pressure and non-pressure scenarios.

  1.1: TimedRollingFileAppender新增方法 resetTimedRollingFilleConfig(String datePattern),可根据日志滚动策略对日志进行动态配置
  1.2: LoadTestAwareAppender 新增rest方法,根据日期策略重置nonLoadTestTraceAppender和loadTestTraceAppender
Copy link

coderabbitai bot commented Jul 4, 2024

Walkthrough

The LoadTestAwareAppender class has been refactored to use TimedRollingFileAppender instances instead of TraceAppender instances for both load and non-load scenarios. This refactoring involved updating constructors, creation methods, and other method implementations to accommodate the new appender type. Additionally, a new method to reset rolling file configurations was added to both LoadTestAwareAppender and TimedRollingFileAppender.

Changes

Files Change Summary
tracer-core/src/main/java/.../LoadTestAwareAppender.java Refactored to use TimedRollingFileAppender instead of TraceAppender, updated various methods, added new method for resetting rolling file configurations.
tracer-core/src/main/java/.../TimedRollingFileAppender.java Added a new method resetTimedRollingFileConfig to reset the rolling file configurations based on a specified date pattern.

Poem

In the world of LoadTestAware, we weave,
With TimedRollingFileAppender, logs reprieve.
Under pressure or serene,
Our logs roll clean.
Reset and flush in seamless dance,
In the code, we took a chance.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0a5375a and 059e911.

Files selected for processing (2)
  • tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/LoadTestAwareAppender.java (1 hunks)
  • tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/TimedRollingFileAppender.java (1 hunks)
Additional comments not posted (6)
tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/LoadTestAwareAppender.java (5)

25-26: Change Approved: Replace TraceAppender with TimedRollingFileAppender

The replacement of TraceAppender with TimedRollingFileAppender aligns with the new logging strategy.


28-29: Change Approved: Constructor Update

The constructor now initializes TimedRollingFileAppender instances, which is consistent with the new logging strategy.


36-39: Change Approved: Creation Method Update

The creation method now initializes TimedRollingFileAppender instances, which is consistent with the new logging strategy.


46-49: Change Approved: Creation Method Update with Parameters

The creation method now initializes TimedRollingFileAppender instances with additional parameters, which is consistent with the new logging strategy.


75-77: Change Approved: New reset Method

The new reset method correctly resets the configuration of TimedRollingFileAppender instances.

tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/TimedRollingFileAppender.java (1)

134-143: Change Approved: New resetTimedRollingFileConfig Method

The new method correctly resets the configuration based on a specified date pattern and recalculates the next check time for file rolling.

public final class LoadTestAwareAppender implements TraceAppender {
private TimedRollingFileAppender nonLoadTestTraceAppender;
private TimedRollingFileAppender loadTestTraceAppender;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把注释都加回来

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释还原了

+ File.separator
+ logName, append);
TimedRollingFileAppender nonLoadTestTraceAppender = new TimedRollingFileAppender(logName,
append);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码格式有问题?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我这个是idea格式化之后的代码,要不要还原成和之前一样的格式

2.代码格式化
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 059e911 and dba75b1.

Files selected for processing (1)
  • tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/LoadTestAwareAppender.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tracer-core/src/main/java/com/alipay/common/tracer/core/appender/file/LoadTestAwareAppender.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants