Boost logo

Boost Users :

Subject: Re: [Boost-users] How to wrap boost::log class to user?
From: GMX (amainik_at_[hidden])
Date: 2016-11-14 08:50:07


  Originalnachricht  
Von: Leon Mlakar
Gesendet: Montag, 14. November 2016 13:05
An: boost-users_at_[hidden]
Antwort an: boost-users_at_[hidden]
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_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net