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

*: Combine LOG_XXX and LOG_FMT_XXX #5512

Merged
merged 8 commits into from Aug 2, 2022

Conversation

fuzhe1989
Copy link
Contributor

@fuzhe1989 fuzhe1989 commented Jul 30, 2022

Signed-off-by: fuzhe1989 fuzhe1989@gmail.com

What problem does this PR solve?

Issue Number: ref #5511

Problem Summary:

What is changed and how it works?

Overload macros by arg count.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Signed-off-by: fuzhe1989 <fuzhe1989@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 30, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JaySon-Huang
  • ywqzzy

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 30, 2022
@fuzhe1989
Copy link
Contributor Author

Hi @JaySon-Huang, @zanmato1984, @solotzg could you please take a look at this pr at your earliest convenient time?

Signed-off-by: fuzhe1989 <fuzhe1989@gmail.com>
@fuzhe1989
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Jul 30, 2022

Coverage for changed files

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
logger_useful.h                    10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Files which contain no functions:
MacroUtils.h                        0                 0         -           0                 0         -           0                 0         -           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                              10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18924      9440             50.12%    213890  95337        55.43%

full coverage report (for internal network access only)

@fuzhe1989
Copy link
Contributor Author

/run-all-tests

@fuzhe1989
Copy link
Contributor Author

/run-all-tests

@fuzhe1989
Copy link
Contributor Author

/rebuild

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 1, 2022

Coverage for changed files

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
logger_useful.h                    10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Files which contain no functions:
MacroUtils.h                        0                 0         -           0                 0         -           0                 0         -           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                              10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18924      9440             50.12%    213890  95348        55.42%

full coverage report (for internal network access only)

@ywqzzy
Copy link
Contributor

ywqzzy commented Aug 1, 2022

/rebuild

1 similar comment
@fuzhe1989
Copy link
Contributor Author

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

2 similar comments
@fuzhe1989
Copy link
Contributor Author

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

3 similar comments
@fuzhe1989
Copy link
Contributor Author

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

3 similar comments
@JaySon-Huang
Copy link
Contributor

/rebuild

@fuzhe1989
Copy link
Contributor Author

/rebuild

@ywqzzy
Copy link
Contributor

ywqzzy commented Aug 2, 2022

/rebuild

@fuzhe1989
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot
Copy link
Member

@leiysky: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@JaySon-Huang
Copy link
Contributor

/run-all-tests

} \
} while (false)

#define LOG_IMPL_CHOSER(...) TF_GET_29TH_ARG(__VA_ARGS__, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_1, LOG_IMPL_0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you tell me why have 29 args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because in our repo the maximum of arguments count is 26.

@sre-bot
Copy link
Collaborator

sre-bot commented Aug 2, 2022

Coverage for changed files

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
logger_useful.h                    10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Files which contain no functions:
MacroUtils.h                        0                 0         -           0                 0         -           0                 0         -           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                              10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18924      9440             50.12%    213890  95346        55.42%

full coverage report (for internal network access only)

Copy link
Contributor

@ywqzzy ywqzzy left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 2, 2022
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 2, 2022
@JaySon-Huang
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 164c473

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 2, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Aug 2, 2022

Coverage for changed files

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
logger_useful.h                    10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Files which contain no functions:
MacroUtils.h                        0                 0         -           0                 0         -           0                 0         -           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                              10                 0   100.00%           2                 0   100.00%           9                 3    66.67%           6                 0   100.00%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18924      9440             50.12%    213890  95373        55.41%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit bebd45a into pingcap:master Aug 2, 2022
@fuzhe1989 fuzhe1989 deleted the fuzhe/variadic_macro branch August 2, 2022 03:28
JaySon-Huang pushed a commit to ti-chi-bot/tiflash that referenced this pull request Aug 31, 2022
#define LOG_IMPL(logger, PRIORITY, ...) LOG_IMPL_CHOSER(__VA_ARGS__)(logger, PRIORITY, __VA_ARGS__)
// clang-format on

#define LOG_TRACE(logger, ...) LOG_IMPL(logger, Poco::Message::PRIO_TRACE, __VA_ARGS__)
Copy link
Member

@breezewish breezewish Sep 3, 2022

Choose a reason for hiding this comment

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

According to the doc:

A Message can also contain any number of named parameters that contain additional information about the event that caused the message.

Seems that we can even consider supporting named arguments (instead of fmt differently) in future?

cc @JaySon-Huang

Copy link
Contributor

Choose a reason for hiding this comment

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

Does "named arguments" means a behavior like this?

int val = 12345;
LOG_DEBUG(log, "log some value"; val);
// generate a log "log some value [val=12345]"

As Poco::Message copy the key, value to a map<string, string> then put it into the format buffer. I'm wondering whether it will bring performance regression for logging. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spdlog may be a good alternative considering performance. It also has many convenient features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants