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 fd045cc..f3212d9 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 @@ -42,10 +43,15 @@ using namespace nx::kit; static int maxWaitSecondsAfterMount = 10; +void enableLogging(std::string iniDir); + Engine::Engine(Plugin *plugin) : nx::sdk::analytics::Engine(NX_DEBUG_ENABLE_OUTPUT, plugin->instanceId()), m_plugin(plugin), m_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; @@ -110,6 +116,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 {