-
Notifications
You must be signed in to change notification settings - Fork 1k
chore: polishing. put basic usage info to stdout using one call to a void messing lines #5019
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
Conversation
…oid messing lines
src/server/dfly_main.cc
Outdated
for (const auto& dir : google::GetLoggingDirectories()) { | ||
const string_view maybe_slash = absl::EndsWith(dir, "/") ? "" : "/"; | ||
std::cout << dir << maybe_slash << "dragonfly.*\n"; | ||
output += std::string(dir) + std::string(maybe_slash) + "dragonfly.*\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.
absl::StrCat
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.
Fixed.
std::cout << " @@ \n"; | ||
std::cout << " .. \n"; | ||
std::cout << "* Logs will be written to the first available of the following paths:\n"; | ||
std::string output = |
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.
string_view
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.
It changes below.
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.
it's fine to use std::string. Who cares 🤷 Same for absl:: variants. Just commented them for completeness
src/server/dfly_main.cc
Outdated
for (const auto& dir : google::GetLoggingDirectories()) { | ||
const string_view maybe_slash = absl::EndsWith(dir, "/") ? "" : "/"; | ||
std::cout << dir << maybe_slash << "dragonfly.*\n"; | ||
output += std::string(dir) + std::string(maybe_slash) + "dragonfly.*\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.
There is also absl::StrCat
or absl::StrAppend
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.
Fixed.
"* For the available flags type dragonfly [--help | --helpfull]\n" | ||
"* Documentation can be found at: https://www.dragonflydb.io/docs\n"; | ||
|
||
std::cout << output; |
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.
std::cout << output; | |
std::cout << output << std::endl; |
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.
better flush the output buffer
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.
I want to avoid more than one <<. This is the main idea of this change.
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.
But if you don't flush
the internal io buffer, how do you know it gets printed ? cout
uses buffered io
so unless you flush with std::endl
you don't know if it actually reached the output/terminal
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.
I added explicit flush. It solves the instant write. But the main idea was to avoid breaking lines and messing them up.
Can you plz elaborate:
|
I updated the description with the provided example. |
Sometimes we can see the lines being messed with at the start. This change fixes that.
The example from Grafana log:
