You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
It would be nice if trantor::LogStream class inherited std::ostream interface.
Currently, in our project we have to implement 2 stream redirections, or use templatized implementation, for every model class, to cover both cases:
Redirection to trantor::LogStream
Redirection to std::ostream.
We are using LogStream for logging with trantor, and std::ostream to be compatible with standard C++ library, ex, to be able to use std::stringstream.
If trantor::LogStream inherited std::ostream interface, the users could implement only one redirection function per each model class.
We can propose 2 solutions:
Create new proxy classes, which would implement std::streambuf/std::ostream interfaces correspondingly and seamlessly redirect all the calls into trantor::LogStream or trantor::LogStream::Buffer (via 'append' method) like this (this is just an example):
This will require another logger, and a new implementation of LOG_INFO, LOG_DEBUG etc macros, since this utilises another stream implementation.
Inherit trantor::LogStream from std::ostream and implement forwarding into trantor's LogStream::Buffer in there (old interfaces are left where they are, but this option will require additional effort to maintain backward capability).
Actually, we have already implemented option 1 in our codebase, and it proved to work fine, but the drawback is that now we have to maintain 2 loggers - the old trantor's native logger, and the new std::ostream-compatible logger. If it was possible to implement either of options 1 or 2 in the trantor library directly, it would be nice.
What does the community think about this idea?
The text was updated successfully, but these errors were encountered:
Hello!
It would be nice if trantor::LogStream class inherited std::ostream interface.
Currently, in our project we have to implement 2 stream redirections, or use templatized implementation, for every model class, to cover both cases:
We are using LogStream for logging with trantor, and std::ostream to be compatible with standard C++ library, ex, to be able to use std::stringstream.
If trantor::LogStream inherited std::ostream interface, the users could implement only one redirection function per each model class.
We can propose 2 solutions:
This will require another logger, and a new implementation of LOG_INFO, LOG_DEBUG etc macros, since this utilises another stream implementation.
Actually, we have already implemented option 1 in our codebase, and it proved to work fine, but the drawback is that now we have to maintain 2 loggers - the old trantor's native logger, and the new std::ostream-compatible logger. If it was possible to implement either of options 1 or 2 in the trantor library directly, it would be nice.
What does the community think about this idea?
The text was updated successfully, but these errors were encountered: