From ff6d8a87f9569a42c7827428f2329280c9b633b9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 1 Aug 2016 01:16:15 -0400 Subject: Implement LV2 log extension as host Only print color logs if output is a terminal. --- ingen/Log.hpp | 22 +++++++++++++++++++++- ingen/URIs.hpp | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'ingen') diff --git a/ingen/Log.hpp b/ingen/Log.hpp index 6c88e9a4..a868e714 100644 --- a/ingen/Log.hpp +++ b/ingen/Log.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2015 David Robillard + Copyright 2007-2016 David Robillard Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -21,6 +21,7 @@ #include +#include "ingen/LV2Features.hpp" #include "ingen/ingen.h" #include "lv2/lv2plug.in/ns/ext/log/log.h" @@ -34,20 +35,39 @@ class INGEN_API Log { public: Log(LV2_Log_Log* log, URIs& uris); + struct Feature : public LV2Features::Feature { + const char* uri() const { return LV2_LOG__log; } + + SPtr feature(World* world, Node* block); + + struct Handle { + LV2_Log_Log lv2_log; + Log* log; + Node* node; + }; + }; + void error(const std::string& msg); void info(const std::string& msg); 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); + void set_flush(bool f) { _flush = f; } + void set_trace(bool f) { _trace = f; } private: + void print(FILE* stream, const std::string& msg); + LV2_Log_Log* _log; URIs& _uris; bool _flush; + bool _trace; }; } // namespace Ingen diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp index 52921085..9fc771da 100644 --- a/ingen/URIs.hpp +++ b/ingen/URIs.hpp @@ -127,6 +127,7 @@ public: const Quark ingen_value; const Quark log_Error; const Quark log_Note; + const Quark log_Trace; const Quark log_Warning; const Quark lv2_AudioPort; const Quark lv2_CVPort; -- cgit v1.2.1