diff --git a/src/plugin/settings/device_agent.cpp b/src/plugin/settings/device_agent.cpp index 8f50e5d..a89fff0 100644 --- a/src/plugin/settings/device_agent.cpp +++ b/src/plugin/settings/device_agent.cpp @@ -5,7 +5,6 @@ #include -#define NX_PRINT_PREFIX (this->logUtils.printPrefix) #include #include #include diff --git a/src/plugin/settings/engine.cpp b/src/plugin/settings/engine.cpp index 20f438a..c612094 100644 --- a/src/plugin/settings/engine.cpp +++ b/src/plugin/settings/engine.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -21,8 +22,8 @@ #include "cloudfuse_helper.h" -#define NX_PRINT_PREFIX (this->logUtils.printPrefix) #include +#include #include #include #include @@ -40,10 +41,15 @@ using namespace nx::sdk; using namespace nx::sdk::analytics; using namespace nx::kit; +void enableLogging(std::string iniDir); + Engine::Engine(Plugin *plugin) : nx::sdk::analytics::Engine(NX_DEBUG_ENABLE_OUTPUT, plugin->instanceId()), m_plugin(plugin), cfManager() { + // logging will begin the _next_ time the mediaserver starts + enableLogging(IniConfig::iniFilesDir()); NX_PRINT << "cloudfuse Engine::Engine"; + for (const auto &entry : kActiveSettingsRules) { const ActiveSettingsBuilder::ActiveSettingKey key = entry.first; @@ -105,6 +111,26 @@ std::string Engine::manifestString() const return result; } +void enableLogging(std::string iniDir) +{ + // enable logging by touching stdout and stderr redirect files + if (!fs::is_directory(iniDir)) + { + fs::create_directories(iniDir); + } + const std::string processName = utils::getProcessName(); + const std::string stdoutFilename = iniDir + processName + "_stdout.log"; + const std::string stderrFilename = iniDir + processName + "_stderr.log"; + if (!fs::exists(stdoutFilename) || !fs::exists(stderrFilename)) + { + NX_PRINT << "cloudfuse Engine::enableLogging - creating files"; + std::ofstream stdoutFile(stdoutFilename); + std::ofstream stderrFile(stderrFilename); + // the service will need to be restarted for logging to actually begin + } + NX_PRINT << "cloudfuse Engine::enableLogging - plugin stderr logging file: " + stderrFilename; +} + bool Engine::processActiveSettings(Json::object *model, std::map *values, const std::vector &settingIdsToUpdate) const {