|
|
@@ -25,6 +25,14 @@
|
|
|
|
|
|
#define VA_LOG(level) VA_LOGN(level, c_logger::LOGF_MAX_SIZE)
|
|
|
|
|
|
+#define MAKE_LOGGER_FMT(lvl) \
|
|
|
+ inline void lvl##f(char const * fmt, ...) { VA_LOG(level::lvl); } \
|
|
|
+ inline void lvl##nf(size_t n, char const * fmt, ...) { \
|
|
|
+ VA_LOGN(level::lvl, n); \
|
|
|
+ } \
|
|
|
+ inline void lvl(char const * msg) { log(level::lvl, msg); } \
|
|
|
+ inline void lvl(std::string const & msg) { log(level::lvl, msg); }
|
|
|
+
|
|
|
namespace logging {
|
|
|
class logger_impl;
|
|
|
|
|
|
@@ -32,43 +40,16 @@ namespace logging {
|
|
|
public:
|
|
|
static const size_t LOGF_MAX_SIZE = 2048;
|
|
|
public:
|
|
|
- inline void tracef(char const* fmt, ...) { VA_LOG(LTRACE); }
|
|
|
- inline void tracenf(size_t n, char const* fmt, ...) { VA_LOGN(LTRACE, n); }
|
|
|
- inline void trace(char const* msg) { log(LTRACE, msg); }
|
|
|
- inline void trace(std::string const& msg) { log(LTRACE, msg); }
|
|
|
-
|
|
|
- inline void debugf(char const* fmt, ...) { VA_LOG(LDEBUG); }
|
|
|
- inline void debugnf(size_t n, char const* fmt, ...) { VA_LOGN(LDEBUG, n); }
|
|
|
- inline void debug(char const* msg) { log(LDEBUG, msg); }
|
|
|
- inline void debug(std::string const& msg) { log(LDEBUG, msg); }
|
|
|
-
|
|
|
- inline void infof(char const* fmt, ...) { VA_LOG(LINFO); }
|
|
|
- inline void infonf(size_t n, char const* fmt, ...) { VA_LOGN(LINFO, n); }
|
|
|
- inline void info(char const* msg) { log(LINFO, msg); }
|
|
|
- inline void info(std::string const& msg) { log(LINFO, msg); }
|
|
|
-
|
|
|
- inline void warnf(char const* fmt, ...) { VA_LOG(LWARNING); }
|
|
|
- inline void warnnf(size_t n, char const* fmt, ...) { VA_LOGN(LWARNING, n); }
|
|
|
- inline void warn(char const* msg) { log(LWARNING, msg); }
|
|
|
- inline void warn(std::string const& msg) { log(LWARNING, msg); }
|
|
|
-
|
|
|
- inline void errorf(char const* fmt, ...) { VA_LOG(LERROR); }
|
|
|
- inline void errornf(size_t n, char const* fmt, ...) { VA_LOGN(LERROR, n); }
|
|
|
- inline void error(char const* msg) { log(LERROR, msg); }
|
|
|
- inline void error(std::string const& msg) { log(LERROR, msg); }
|
|
|
-
|
|
|
- inline void criticalf(char const* fmt, ...) { VA_LOG(LCRITICAL); }
|
|
|
- inline void criticalnf(size_t n, char const* fmt, ...) { VA_LOGN(LCRITICAL, n); }
|
|
|
- inline void critical(char const* msg) { log(LCRITICAL, msg); }
|
|
|
- inline void critical(std::string const& msg) { log(LCRITICAL, msg); }
|
|
|
-
|
|
|
- inline void fatalf(char const* fmt, ...) { VA_LOG(LFATAL); }
|
|
|
- inline void fatalnf(size_t n, char const* fmt, ...) { VA_LOGN(LFATAL, n); }
|
|
|
- inline void fatal(char const* msg) { log(LFATAL, msg); }
|
|
|
- inline void fatal(std::string const& msg) { log(LFATAL, msg); }
|
|
|
+ MAKE_LOGGER_FMT(trace)
|
|
|
+ MAKE_LOGGER_FMT(debug)
|
|
|
+ MAKE_LOGGER_FMT(info)
|
|
|
+ MAKE_LOGGER_FMT(warn)
|
|
|
+ MAKE_LOGGER_FMT(error)
|
|
|
+ MAKE_LOGGER_FMT(critical)
|
|
|
+ MAKE_LOGGER_FMT(fatal)
|
|
|
|
|
|
template <typename... Args>
|
|
|
- inline void log(log_level ll, std::string const & interp, Args && ...args);
|
|
|
+ inline void log(level ll, std::string const & interp, Args && ...args);
|
|
|
|
|
|
void flush();
|
|
|
|
|
|
@@ -79,11 +60,10 @@ namespace logging {
|
|
|
c_logger(std::string const & name, std::shared_ptr<logger_impl> impl);
|
|
|
|
|
|
private:
|
|
|
- void vlognf(log_level, size_t, char const*, va_list);
|
|
|
- void log(log_level, std::string const&);
|
|
|
+ void vlognf(level, size_t, char const*, va_list);
|
|
|
+ void log(level, std::string const&);
|
|
|
|
|
|
private:
|
|
|
- log_level min_level_;
|
|
|
std::string logger_name_;
|
|
|
std::shared_ptr<logger_impl> impl_;
|
|
|
};
|