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

feat: lazy formatted log #1441

Merged
merged 5 commits into from
Oct 29, 2024
Merged

feat: lazy formatted log #1441

merged 5 commits into from
Oct 29, 2024

Conversation

jizhuozhi
Copy link
Collaborator

Ⅰ. Describe what this PR did

Current logging in wasm-rust needs to be formatted before level checking, it means even log level is less than configured, but the cost of formatting is wasted.

Provides a serials of format log methods, which using Argument as args and formatting message after level checking success.

Ⅱ. Does this pull request fix one issue?

None

Ⅲ. Why don't you add test cases (unit test/integration test)?

None

Ⅳ. Describe how to verify it

None

Ⅴ. Special notes for reviews

None

@jizhuozhi jizhuozhi requested a review from 007gzs as a code owner October 28, 2024 16:07
@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.53%. Comparing base (ef31e09) to head (dcb8516).
Report is 173 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1441      +/-   ##
==========================================
+ Coverage   35.91%   43.53%   +7.62%     
==========================================
  Files          69       76       +7     
  Lines       11576    12320     +744     
==========================================
+ Hits         4157     5364    +1207     
+ Misses       7104     6621     -483     
- Partials      315      335      +20     

see 69 files with indirect coverage changes

Copy link
Collaborator

@007gzs 007gzs left a comment

Choose a reason for hiding this comment

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

log和logf有必要合并下么?比如

fn log(&self, level: LogLevel, msg: &str) {
    self.logf(level, format_args!("{}", msg));
}

现在通用格式化format!("[{}] {}", self.plugin_name, msg); 和level转换写在了两个地方,如果后面想改格式的话需要改多处

Copy link
Collaborator

@007gzs 007gzs left a comment

Choose a reason for hiding this comment

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

LGTM

@007gzs 007gzs merged commit 93c1e5c into alibaba:main Oct 29, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants