Singletion pattern for C++ logger -
i need design logger class used other classed log messages. creating poiner of logger in each of classes , calling method of logger thorugh logger pointer log messages. want design in singleton pattern way , has thread safe. can suggest approach.
forget singleton, make in class static
. want provide macros access log method, example:
#define logdbg(fmt, ...) log::log(__function__, log::level_debug, fmt, ##__va_args__)
which, when implemented singleton need be:
#define logdbg(fmt, ...) log::instance().log(__function__, log::level_debug, fmt, ##__va_args__)
which makes little difference.
Comments
Post a Comment