Capture lilv messages to log files.

Fixes dev-build warnings and build-machine errors.
This commit is contained in:
Robin Davies
2022-03-18 02:20:45 -04:00
parent f93f01ba06
commit d9db32bebb
4 changed files with 15 additions and 13 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ add_custom_command(
set (PIPEDAL_SOURCES set (PIPEDAL_SOURCES
StdOutCapture.hpp StdOutCapture.cpp StdErrorCapture.hpp StdErrorCapture.cpp
Ipv6Helpers.cpp Ipv6Helpers.hpp Ipv6Helpers.cpp Ipv6Helpers.hpp
PluginPreset.cpp PluginPreset.hpp PluginPreset.cpp PluginPreset.hpp
CpuGovernor.cpp CpuGovernor.hpp CpuGovernor.cpp CpuGovernor.hpp
+2 -2
View File
@@ -41,7 +41,7 @@
#include "lv2/lv2plug.in/ns/ext/port-groups/port-groups.h" #include "lv2/lv2plug.in/ns/ext/port-groups/port-groups.h"
#include <fstream> #include <fstream>
#include "PiPedalException.hpp" #include "PiPedalException.hpp"
#include "StdOutCapture.hpp" #include "StdErrorCapture.hpp"
#include "Locale.hpp" #include "Locale.hpp"
@@ -391,7 +391,7 @@ void Lv2Host::Load(const char *lv2Path)
free_world(); free_world();
setenv("LV2_PATH", lv2Path, true); setenv("LV2_PATH", lv2Path, true);
StdOutCapture stdoutCapture; // captures lilv messages written to STDOUT. StdErrorCapture stdoutCapture; // captures lilv messages written to STDOUT.
pWorld = lilv_world_new(); pWorld = lilv_world_new();
{ {
@@ -18,7 +18,7 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "StdOutCapture.hpp" #include "StdErrorCapture.hpp"
#include <cstdio> #include <cstdio>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@@ -38,18 +38,19 @@
using namespace pipedal; using namespace pipedal;
constexpr int STDOUT_HANDLE = 2; constexpr int STDOUT_HANDLE = 2;
StdOutCapture::StdOutCapture() StdErrorCapture::StdErrorCapture()
{ {
this->tempFileName = std::tmpnam(nullptr); char filename[] = "/tmp/pipedal.XXXXXX";
int redirectHandle = mkstemp(filename);
this->tempFileName = filename;
int redirectHandle = open(tempFileName.c_str(),O_CREAT | O_WRONLY | O_TRUNC);
this->oldStdout = dup(STDOUT_HANDLE); this->oldStdout = dup(STDOUT_HANDLE);
dup2(redirectHandle,STDOUT_HANDLE); dup2(redirectHandle,STDOUT_HANDLE);
close(redirectHandle); close(redirectHandle);
} }
StdOutCapture::~StdOutCapture() StdErrorCapture::~StdErrorCapture()
{ {
EndCapture(); EndCapture();
if (tempFileName.length() != 0) if (tempFileName.length() != 0)
@@ -58,7 +59,7 @@ StdOutCapture::~StdOutCapture()
} }
} }
void StdOutCapture::EndCapture() void StdErrorCapture::EndCapture()
{ {
if (this->oldStdout != -1) if (this->oldStdout != -1)
@@ -70,7 +71,7 @@ void StdOutCapture::EndCapture()
} }
} }
std::vector<std::string> StdOutCapture::GetOutputLines() { std::vector<std::string> StdErrorCapture::GetOutputLines() {
EndCapture(); EndCapture();
std::vector<std::string> result; std::vector<std::string> result;
@@ -20,13 +20,14 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector>
namespace pipedal { namespace pipedal {
class StdOutCapture { class StdErrorCapture {
public: public:
StdOutCapture(); StdErrorCapture();
~StdOutCapture(); ~StdErrorCapture();
void EndCapture(); void EndCapture();