Fixed virtual camera removal (issue #18). Send manager log to a file.

This commit is contained in:
Gonzalo Exequiel Pedone 2021-06-09 17:37:36 -03:00
parent b7f1ff83b6
commit 03a21de594
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF
6 changed files with 28 additions and 4 deletions

View file

@ -162,6 +162,10 @@ namespace AkVCam {
AkVCam::CmdParser::CmdParser()
{
this->d = new CmdParserPrivate();
auto logFile = this->d->m_ipcBridge.logPath("AkVCamManager");
AkLogInfo() << "Sending debug output to " << logFile << std::endl;
AkVCam::Logger::setLogFile(logFile);
this->d->m_commands.push_back({});
this->setDefaultFuntion(AKVCAM_BIND_FUNC(CmdParserPrivate::defaultHandler));
this->addFlags("",

View file

@ -100,6 +100,7 @@ namespace AkVCam
void setPicture(const std::string &picture);
int logLevel() const;
void setLogLevel(int logLevel);
std::string logPath(const std::string &logName={}) const;
// Register the peer to the global server.
bool registerPeer();

View file

@ -182,6 +182,15 @@ void AkVCam::IpcBridge::setLogLevel(int logLevel)
Logger::setLogLevel(logLevel);
}
std::string AkVCam::IpcBridge::logPath(const std::string &logName) const
{
if (logName.empty())
return {};
return AkVCam::Preferences::readString("logfile",
"/tmp/" + logName + ".log");
}
bool AkVCam::IpcBridge::registerPeer()
{
AkLogFunction();

View file

@ -308,10 +308,8 @@ bool AkVCam::Preferences::removeCamera(const std::string &path)
if (cameraIndex < 0)
return false;
bool ok = true;
ok &= cameraSetFormats(size_t(cameraIndex), {});
auto nCameras = camerasCount();
bool ok = true;
ok &= deleteKey("Cameras\\" + std::to_string(cameraIndex + 1) + '\\', true);
for (auto i = size_t(cameraIndex + 1); i < nCameras; i++)
@ -319,6 +317,8 @@ bool AkVCam::Preferences::removeCamera(const std::string &path)
"Cameras\\" + std::to_string(i),
true);
ok &= deleteKey("Cameras\\" + std::to_string(nCameras) + '\\', true);
if (nCameras > 1)
ok &= write("Cameras\\size", int(nCameras - 1), true);
else

View file

@ -975,7 +975,7 @@ LSTATUS AkVCam::copyTree(HKEY src, LPCSTR subkey, HKEY dst, REGSAM samFlags)
DWORD nameLen = len;
DWORD dataType = 0;
BYTE *data = new BYTE[maxValueLen];
DWORD dataSize = 0;
DWORD dataSize = maxValueLen;
result = RegEnumValue(hkeyFrom,
i,
name,

View file

@ -194,6 +194,16 @@ void AkVCam::IpcBridge::setLogLevel(int logLevel)
Logger::setLogLevel(logLevel);
}
std::string AkVCam::IpcBridge::logPath(const std::string &logName) const
{
if (logName.empty())
return {};
auto defaultLogFile = AkVCam::tempPath() + "\\" + logName + ".log";
return AkVCam::Preferences::readString("logfile", defaultLogFile);
}
bool AkVCam::IpcBridge::registerPeer()
{
AkLogFunction();