Herb Sutter just made me feel better with this:
http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-b...
Thanks Vicente!
Mauricio Carneiro, Ph.D.
http://www.broadinstitute.org/~carneiro/
On Sun, Nov 24, 2013 at 3:42 AM, Mauricio Carneiro
apologies for my quick-without-thinking reply, I didn't realize you meant the 'mutable' keyword!
You're right that making the logger mutable would allow it in const methods. It works right now, thank you.
Is this a reasonable solution? Or having a mutable member in the class is considered "code smell" ?
Mauricio Carneiro, Ph.D. http://www.broadinstitute.org/~carneiro/
On Sun, Nov 24, 2013 at 3:21 AM, Mauricio Carneiro
wrote: I am declaring the logger member mutable, the problem is that every method in the class that uses the logger now has to be non-const because they are changing the state of a member of the class.
I believe there is a better design out there, and I'd like to hear how you guys have been using the logger in your classes then, I must be doing it wrong (or just ugly).
Thank you,
Mauricio Carneiro, Ph.D. http://www.broadinstitute.org/~carneiro/
On Sun, Nov 24, 2013 at 3:07 AM, Vicente J. Botet Escriba < vicente.botet@wanadoo.fr> wrote:
Le 24/11/13 08:48, Mauricio Carneiro a écrit :
I am trying to use a severity channel logger but I hit the problem with BOOST_LOG_SEV not being a const method -- I'm thinking because of both open_record() and push_record()
This will basically force me to make all methods in my classes not const because they want to write out to their loggers. I can't really afford to do that -- so I'm restricted to global loggers at the moment.
In my current implementation, each class has a logger with the class name as the channel (initialized in their constructors), and it issues log messages at any point with BOOST_LOG_SEV(this->logger, level)
You can declare your logger member mutable.
Vicente
I'd love to hear the reason behind the non-constness and if my design is not the intended for Boost::Log.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users