views:

238

answers:

1

i think it makes sense to use boost::singleton together with a boost::logger, so that all the objects in the executable can access the same logger and dump strings to it.

class logger_singleton
  : public boost::mutexed_singleton<logger_singleton>
{
  private
   boost::logger blogger;

  public:

    logger_singleton(boost::restricted);

    // public interface, e.g:
    int log_this_string(const std::string &a){blogger->strm()<<a;}
};

has anyone ever tried this and what do you think about it?

+2  A: 

I don't think there is a boost logger library yet. If there were i suspect it would be designed such that using it with a singleton class as you describe would not be necessary.

jon hanson
There have been multiple attempts at designing a boost log library, but none has yet been accepted in boost
Benoît
yah, Benoit is right. I am using the one by John Torjo. However, that logger seems to be stuck in the process of being accepted by Boost. Is there anyone familiar with this matter and share some information. I really dont want to re-invent the wheel and write my own logger. (and I am lazy too)
ccfenix
John's blog has been dormant for some time so i'm not sure his logger is moving forward w.r.t. boost.
jon hanson