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() AkVCam::CmdParser::CmdParser()
{ {
this->d = new CmdParserPrivate(); 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->d->m_commands.push_back({});
this->setDefaultFuntion(AKVCAM_BIND_FUNC(CmdParserPrivate::defaultHandler)); this->setDefaultFuntion(AKVCAM_BIND_FUNC(CmdParserPrivate::defaultHandler));
this->addFlags("", this->addFlags("",

View file

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

View file

@ -182,6 +182,15 @@ void AkVCam::IpcBridge::setLogLevel(int logLevel)
Logger::setLogLevel(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() bool AkVCam::IpcBridge::registerPeer()
{ {
AkLogFunction(); AkLogFunction();

View file

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

View file

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

View file

@ -194,6 +194,16 @@ void AkVCam::IpcBridge::setLogLevel(int logLevel)
Logger::setLogLevel(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() bool AkVCam::IpcBridge::registerPeer()
{ {
AkLogFunction(); AkLogFunction();