-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[core] Use spdlog fd sink within pipe logger #50173
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: dentiny <[email protected]>
d6699e1
to
942fd8f
Compare
Signed-off-by: dentiny <[email protected]>
942fd8f
to
46bf843
Compare
auto logger_sink = std::make_shared<non_owned_fd_sink_st>(handle); | ||
auto logger = std::make_shared<spdlog::logger>( | ||
/*name=*/absl::StrFormat("pipe-logger-%s", file_path), std::move(logger_sink)); | ||
logger->set_level(spdlog::level::info); | ||
logger->set_pattern("%v"); // Only message string is logged. | ||
|
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.
This is the case for no tee no rotation? In this case, we don't write to the 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.
Yes you're right, logger is not necessity here, but otherwise we will have two implementation for StreamRedirectionHandle
,
- one using file descriptor, and take
flush_fn
- another using logger, no need for
flush_fn
, which beats the purpose for this PR to simplify code structure
@@ -224,7 +224,7 @@ TEST(PipeLoggerCompatTest, CompatibilityTest) { | |||
stream_redirection_handle.Close(); | |||
|
|||
const std::string stdout_content = testing::internal::GetCapturedStdout(); | |||
EXPECT_EQ(stdout_content, kContent); | |||
EXPECT_EQ(stdout_content, "hello\nworld\n"); |
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.
why changing this? it should just match kContent right
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.
No, in the pr we use spdlog for all sinks, which means newliner at the end for everything.
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.
Yes, but for this test, kContent already has the newliner at the end.
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.
OK, thats for code style consistency, we're using raw string to match elsewhere
Signed-off-by: dentiny <[email protected]>
Signed-off-by: dentiny <[email protected]>
fb006b7
to
3f4dc0b
Compare
Signed-off-by: dentiny <[email protected]>
This PR is the followup for #50144, which integrates FD sink to the pipe logger.
The benefit is we have less file descriptor related code within pipe logger, and all write, flush and close feature handled in spdlog logger.
One behavior change, we use default formatter for all possible sinks, which appends newliner to each message.