Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into no-return-on-error
Browse files Browse the repository at this point in the history
  • Loading branch information
foodprocessor committed Aug 23, 2024
2 parents 4e3870b + 70b03e3 commit 0d1f5de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/plugin/settings/device_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>

#define NX_PRINT_PREFIX (this->logUtils.printPrefix)
#include <nx/kit/debug.h>
#include <nx/kit/utils.h>
#include <nx/sdk/helpers/active_setting_changed_response.h>
Expand Down
28 changes: 27 additions & 1 deletion 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 @@ -21,8 +22,8 @@

#include "cloudfuse_helper.h"

#define NX_PRINT_PREFIX (this->logUtils.printPrefix)
#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 @@ -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;
Expand Down Expand Up @@ -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<std::string, std::string> *values,
const std::vector<std::string> &settingIdsToUpdate) const
{
Expand Down

0 comments on commit 0d1f5de

Please sign in to comment.