Boost logo

Boost :

From: Boris (boriss_at_[hidden])
Date: 2008-08-20 08:10:21


Currently I'm writing messages to a file with:

BOOST_LOG(mylogger) << __FUNCSIG__ << " message text";

I'd prefer if the function signature (let's assume for now that the macro
is supported by all compilers) is written automatically without me having
to add __FUNCSIG__ everywhere. From what I understand I can't simply add
an attribute to the logger as __FUNCSIG__ would then be used in another
function (and thus a different function signature would be written).

Looking around in the documentation I found BOOST_LOG_WITH_PARAMS (see
http://boost-log.sourceforge.net/libs/log/doc/html/BOOST_LOG_WITH_PARAMS.html).
It makes me think that I could define my own BOOST_LOG macro somehow like
this:

#define BOOST_LOG_FUNCSIG(logger)\
     BOOST_LOG_WITH_PARAMS((logger),
(::boost::log::sources::keywords::funcsignature = (__FUNCSIG__)))

I see that the macro BOOST_LOG_SEV is defined similarly in
severity_logger.hpp. However I also see that some more code has to be
added to the logger to make the logger understand what to do with the
keyword. For example in the severity logger in open_record() the
appropriate attribute is set if the severity keyword is found. That means
I would need to create a new logger and check for my new funcsignature
attribute in open_record() if I want the function signature to be written
automatically? Is there another way to do this more easily?

Boris


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