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 }})

@phobosxy

i-vovk

@i-vovk 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.

@i-vovk

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).

@phobosxy

update by comments in new patchset

i-vovk

@i-vovk

This comment was marked as resolved.

i-vovk

Sivanev Ilya added 6 commits

February 16, 2022 11:44

Sivanev Ilya added 6 commits

February 16, 2022 16:19

i-vovk

Sivanev Ilya added 4 commits

February 17, 2022 16:29

i-vovk

@i-vovk i-vovk changed the titleCCT-126: use log callback function for connection events; implement logger facility and support its' overriding;

Feb 17, 2022

2 participants

@phobosxy @i-vovk