-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add ability to redirect all prints #75
base: master
Are you sure you want to change the base?
Conversation
85b5de0
to
8586742
Compare
This looks really good. Awesome technique to just pass a stream. I always thought about the best technique for redirectable log output and this may be it. |
*/ | ||
FINEFTP_EXPORT FtpServer(const std::string& address, uint16_t port = 21); | ||
FINEFTP_EXPORT FtpServer(const std::string& address, const uint16_t port = 21, std::ostream& output = std::cout, std::ostream& error = std::cerr); |
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.
port
should not be const, as it is passed by value (will give warnings otherwise)
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 have no issue reverting it, but I never saw an issue with a const for any C or C++ int types when by-value is used (by-ref might be an issue)
(I try to use const
on every param method to avoid typos or incorrect assignment)
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.
Can you give an example of where you might think it will fail?
Thank you :) but you did 99.9% of the work with this awesome library 🥇 I see it it failing on some windows builds in the CI/CD and pushed a fix - please trigger the workflow again. |
@FlorianReimold I've used CMake Let me know if you prefer I squash those Also, can you please run |
I let clang tidy check the code. There were no additional warnings, except from the consts. I fixed them. I am currently looking at the Constructor API. For instance, the following call is technically fine: FtpServer("127.0.0.1", my_stream); However, this only sets the "normal" log stream, not the error stream, creating the following situation:
I don't really like that, I think any user who passes only 1 stream would expect both the normal output and error-output would end up in that stream. I suggest the following:
What do you think? |
Still curious as to why you got that error.
Added constructor methods to inforce both or none. |
Added
output
(which defaults tostd::cout
) anderror
(which defaults tostd::cerr
) to allow easier redirect of all prints.Useful when used in a daemon for example or when using a more complex system like spdlog