Boost logo

Boost Users :

From: Mojmir Svoboda (mojmir.svoboda_at_[hidden])
Date: 2008-06-10 06:27:44

hello, John :)

> At this time, my library already does this - you can certainly specify

going quickly through your code i definitly must admit you are farer
than i am. there's no apparent reason start new thingy. for example i'd
probably never mess with internationalization ;)

> whether you want thread-safety or not, and the lib is certainly efficient.

can you give me some hints in the right direction, please? i mean
some general advices "use this if you want be small, this if you want
be fast, avoid that at all costs etc". i'd like both, of course.

i started with your sample and got it down to 12kB (assume 5k is C
helloworld). that's not quite bad, i suppose, but still twice
as it should be ;-P

there are still 9 allocation - there is some vector at initialization
time, but i'd have to read the sources more carefully. perhaps
you could point out these places where expensive and other interesting
things pop up.

minor issues i found:
 - logger.hpp:248 when cache is off, source cannot be compiled
        (missing ifdef probably)
 - pthreads are detected incorrecty. even in singlethr model mutex
    is required.
 - it would be nice if it can compile with -fno-rtti -fno-exceptions
    (op_equal and shared_ptr) see *)

    *) note that it would be nice that all boost code that does not really
       need rtti could switch it off

(fedora7, boost-1_35_0, gcc-4.1.2, bjam not used)

best regards,



#include <cstdio>
#include <boost/logging/logging.hpp>
#include <boost/logging/format.hpp>

using namespace boost::logging;

struct no_gather {
    typedef const char* msg_type ;
    const char * m_msg;
    no_gather() : m_msg(0) {}
    const char * msg() const { return m_msg; }
    void *out(const char* msg) { m_msg = msg; return this; }

struct printf_t : destination::is_generic
    void operator() (char const * msg) const { printf("%s\n", msg); }

typedef logger<no_gather, printf_t> app_log_type;
filter::no_ts * g_log_filter () { static filter::no_ts l; return &l; }
app_log_type* g_log_app () { static app_log_type l; return &l; }

int main () {


    get_logger_base(g_log_app())->read_msg().gather().out("hello world\n");


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at