Originalnachricht Von: Leon Mlakar Gesendet: Montag, 14. November 2016 13:05 An: boost-users@lists.boost.org Antwort an: boost-users@lists.boost.org Betreff: Re: [Boost-users] How to wrap boost::log class to user? On 14.11.2016 12:21, Bruce wrote:
Hi, I am coding a project and I use boost::log. I need to supply the log function to user, but I don't want the user use boost::log directly. I want to wrap the boost::log into my class. But I still want to keep the << cascade feature.
Basically, I need to implement a MyLogger class, which support:
MyLogger(info) << bla bla bla; MyLogger(trace) << bla bla bla;
I'm not sure this is the best way to use Boost.Log. There are at least two reasons why logging macros might be a better idea: 1. Using own operators you cannot implicitly enforce __LINE__, __FILE__ and other compiler generated macros to supplement logged information 2. Boost.Log will not create log record if no sink will accept it. By using logging macros it is easy to ensure that logged information (bla bla bla) is not evaluated if it's not going to be recorded; using own operator overload the logging information will always be evaluated. And in my experience logging information will quickly enough get non-trivial and expensive to calculate. So in consequence logging will slow down you code even in production use with logging thresholds raised to log errors and warnings only. Cheers, Leon _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users