Skip to content

Commit

Permalink
Merge branch 'main' into remove-print-def
Browse files Browse the repository at this point in the history
  • Loading branch information
foodprocessor authored Aug 22, 2024
2 parents 69d12bb + 70b03e3 commit fb587c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/plugin/settings/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <algorithm>
#include <chrono>
#include <filesystem>
#include <fstream>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/evp.h>
Expand All @@ -22,6 +23,7 @@
#include "cloudfuse_helper.h"

#include <nx/kit/debug.h>
#include <nx/kit/ini_config.h>
#include <nx/sdk/helpers/active_setting_changed_response.h>
#include <nx/sdk/helpers/error.h>
#include <utils.h>
Expand All @@ -39,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;
Expand Down Expand Up @@ -104,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<std::string, std::string> *values,
const std::vector<std::string> &settingIdsToUpdate) const
{
Expand Down

0 comments on commit fb587c9

Please sign in to comment.