Boost logo

Boost :

From: John Eddy (johneddy_at_[hidden])
Date: 2005-02-16 14:11:57


> So I guess I define my macro based on your earlier example:
> #define LOG(x) alm.log(basic_entry<>("") \
> << boost::posix_time::microsec_clock::local_time() \
> << "," << __FILE__ \
> << "," << __LINE__ \
> << "," << BOOST_CURRENT_FUNCTION \
> << ":" << (x))
>
You might also consider a simple subclass of basic_entry that does the
formatting in the constructor like:
struct my_entry : public basic_entry<>
{
    template <typename X> my_entry(
        const char* file,
        const int line,
        const char* fctn,
        const X& x
        ) : basic_entry<>()
    {
        basic_entry<>::operator <<
(boost::posix_time::microsec_clock::local_time())
                                << "," << file
                                << "," << line
                                << "," << fctn
                                << ":" << x;
    }
};

Then your macro would read:

#define LOG(tlm, x) tlm.log(my_entry(__FILE__, __LINE__,
BOOST_CURRENT_FUNCTION, x))

John


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk