implement logger facility and support its' overriding; by phobosxy · Pull Request #19 · Tinkoff/stream-client (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
i-vovk left a comment • Loading
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a robust solution. If we want to log error anywhere else this code will be copied. Also, this approach adds a new constructor which is not great either.
This should be done via registering the logger instance once and using it anywhere we want to log something. You should define an appropriate logger interface, define a dummy one (dumps to stdout), and provide free function to register custom (something like stream_client::set_logger(...)). This function may accept a logger instance or just a callback function and construct an instance from it. Also, the logger interface should support log levels.
Another approach would be to propagate such errors outside and give the user ability to process them (they may log, count or take action upon them).
update by comments in new patchset
This comment was marked as resolved.
Sivanev Ilya added 6 commits
Sivanev Ilya added 6 commits
Sivanev Ilya added 4 commits
i-vovk changed the title
CCT-126: use log callback function for connection events; implement logger facility and support its' overriding;