From 532af2452bac2cdd0e2732ad145fdc2b141a4afc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 8 Mar 2019 12:38:19 +0100 Subject: Localise dependency on boost::format and improve logging API --- ingen/Log.hpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'ingen/Log.hpp') diff --git a/ingen/Log.hpp b/ingen/Log.hpp index 4d1bd1ee..000afcbe 100644 --- a/ingen/Log.hpp +++ b/ingen/Log.hpp @@ -25,14 +25,18 @@ #include #include "ingen/LV2Features.hpp" +#include "ingen/fmt.hpp" #include "ingen/ingen.h" #include "lv2/core/lv2.h" #include "lv2/log/log.h" #include "lv2/urid/urid.h" -namespace ingen { +#include +#include +#include +#include -typedef boost::basic_format fmt; +namespace ingen { class Node; class URIs; @@ -63,11 +67,31 @@ public: void warn(const std::string& msg); void trace(const std::string& msg); - inline void error(const fmt& fmt) { error(fmt.str()); } - inline void info(const fmt& fmt) { info(fmt.str()); } - inline void warn(const fmt& fmt) { warn(fmt.str()); } - - int vtprintf(LV2_URID type, const char* fmt, va_list args); + template + void error(const char* format, Args&&... args) + { + error(fmt(format, std::forward(args)...)); + } + + template + void info(const char* format, Args&&... args) + { + info(fmt(format, std::forward(args)...)); + } + + template + void warn(const char* format, Args&&... args) + { + warn(fmt(format, std::forward(args)...)); + } + + template + void trace(const char* format, Args&&... args) + { + trace(fmt(format, std::forward(args)...)); + } + + int vtprintf(LV2_URID type, const char* format, va_list args); void set_flush(bool f) { _flush = f; } void set_trace(bool f) { _trace = f; } -- cgit v1.2.1