Skip to content

Commit

Permalink
VERBOSE -> LOG in mythzoneminder
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Jul 9, 2011
1 parent 2eb493a commit 1f33317
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 54 deletions.
5 changes: 3 additions & 2 deletions mythplugins/mythzoneminder/mythzoneminder/main.cpp
Expand Up @@ -22,6 +22,7 @@
#include <mythmainwindow.h>
#include <myththemedmenu.h>
#include <mythuihelper.h>
#include <mythlogging.h>

//zone minder
#include "zmsettings.h"
Expand Down Expand Up @@ -117,8 +118,8 @@ static int runMenu(QString which_menu)
}
else
{
VERBOSE(VB_IMPORTANT, QString("Couldn't find menu %1 or theme %2")
.arg(which_menu).arg(themedir));
LOG(VB_GENERAL, LOG_ERR, QString("Couldn't find menu %1 or theme %2")
.arg(which_menu).arg(themedir));
delete diag;
return -1;
}
Expand Down
101 changes: 62 additions & 39 deletions mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
Expand Up @@ -12,6 +12,7 @@
#include "mythdialogbox.h"
#include "util.h"
#include "mythmainwindow.h"
#include "mythlogging.h"

//zoneminder
#include "zmclient.h"
Expand Down Expand Up @@ -85,9 +86,9 @@ bool ZMClient::connectToHost(const QString &lhostname, unsigned int lport)
{
++count;

VERBOSE(VB_GENERAL, QString("Connecting to zm server: "
"%1:%2 (try %3 of 10)").arg(m_hostname).arg(m_port)
.arg(count));
LOG(VB_GENERAL, LOG_INFO,
QString("Connecting to zm server: %1:%2 (try %3 of 10)")
.arg(m_hostname).arg(m_port).arg(count));
if (m_socket)
{
m_socket->DownRef();
Expand Down Expand Up @@ -141,11 +142,11 @@ bool ZMClient::sendReceiveStringList(QStringList &strList)

if (!ok)
{
VERBOSE(VB_IMPORTANT, "Connection to mythzmserver lost");
LOG(VB_GENERAL, LOG_NOTICE, "Connection to mythzmserver lost");

if (!connectToHost(m_hostname, m_port))
{
VERBOSE(VB_IMPORTANT, "Re connection to mythzmserver failed");
LOG(VB_GENERAL, LOG_ERR, "Re connection to mythzmserver failed");
return false;
}

Expand All @@ -162,15 +163,17 @@ bool ZMClient::sendReceiveStringList(QStringList &strList)
// the server sends "UNKNOWN_COMMAND" if it did not recognise the command
if (strList[0] == "UNKNOWN_COMMAND")
{
VERBOSE(VB_IMPORTANT, "Somethings is getting passed to the server that it doesn't understand");
LOG(VB_GENERAL, LOG_ERR, "Somethings is getting passed to the server "
"that it doesn't understand");
return false;
}

// the server sends "ERROR" if it failed to process the command
if (strList[0].startsWith("ERROR"))
{
VERBOSE(VB_IMPORTANT, QString("The server failed to process the command. "
"The error was:- \n\t\t\t%1").arg(strList[0]));
LOG(VB_GENERAL, LOG_ERR,
QString("The server failed to process the command. "
"The error was:- \n\t\t\t%1").arg(strList[0]));
return false;
}

Expand All @@ -186,7 +189,7 @@ bool ZMClient::checkProtoVersion(void)
QStringList strList("HELLO");
if (!sendReceiveStringList(strList))
{
VERBOSE(VB_IMPORTANT, QString("Server didn't respond to 'HELLO'!!"));
LOG(VB_GENERAL, LOG_ERR, QString("Server didn't respond to 'HELLO'!!"));

ShowOkPopup(tr("The mythzmserver didn't respond to our request "
"to get the protocol version!!"));
Expand All @@ -195,8 +198,9 @@ bool ZMClient::checkProtoVersion(void)

if (strList[1] != ZM_PROTOCOL_VERSION)
{
VERBOSE(VB_IMPORTANT, QString("Protocol version mismatch (plugin=%1, "
"mythzmserver=%2)").arg(ZM_PROTOCOL_VERSION).arg(strList[1]));
LOG(VB_GENERAL, LOG_ERR,
QString("Protocol version mismatch (plugin=%1, mythzmserver=%2)")
.arg(ZM_PROTOCOL_VERSION).arg(strList[1]));

ShowOkPopup(QString("The mythzmserver uses protocol version %1, "
"but this client only understands version %2. "
Expand All @@ -206,7 +210,8 @@ bool ZMClient::checkProtoVersion(void)
return false;
}

VERBOSE(VB_IMPORTANT, QString("Using protocol version %1").arg(ZM_PROTOCOL_VERSION));
LOG(VB_GENERAL, LOG_INFO,
QString("Using protocol version %1").arg(ZM_PROTOCOL_VERSION));
return true;
}

Expand Down Expand Up @@ -269,7 +274,8 @@ void ZMClient::getMonitorStatus(vector<Monitor*> *monitorList)
int monitorCount = strList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "ZMClient received bad int in getMonitorStatus()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient received bad int in getMonitorStatus()");
return;
}

Expand Down Expand Up @@ -303,15 +309,16 @@ void ZMClient::getEventList(const QString &monitorName, bool oldestFirst,
int eventCount = strList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "ZMClient received bad int in getEventList()");
LOG(VB_GENERAL, LOG_ERR, "ZMClient received bad int in getEventList()");
return;
}

// sanity check
if ((int)(strList.size() - 2) / 6 != eventCount)
{
VERBOSE(VB_IMPORTANT, "ZMClient got a mismatch between the number of events and "
"the expected number of stringlist items in getEventList()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient got a mismatch between the number of events and "
"the expected number of stringlist items in getEventList()");
return;
}

Expand Down Expand Up @@ -350,15 +357,17 @@ void ZMClient::getEventDates(const QString &monitorName, bool oldestFirst,
int dateCount = strList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "ZMClient received bad int in getEventDates()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient received bad int in getEventDates()");
return;
}

// sanity check
if ((int)(strList.size() - 3) != dateCount)
{
VERBOSE(VB_IMPORTANT, "ZMClient got a mismatch between the number of dates and "
"the expected number of stringlist items in getEventDates()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient got a mismatch between the number of dates and "
"the expected number of stringlist items in getEventDates()");
return;
}

Expand All @@ -383,15 +392,16 @@ void ZMClient::getFrameList(int eventID, vector<Frame*> *frameList)
int frameCount = strList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "ZMClient received bad int in getFrameList()");
LOG(VB_GENERAL, LOG_ERR, "ZMClient received bad int in getFrameList()");
return;
}

// sanity check
if ((int)(strList.size() - 2) / 2 != frameCount)
{
VERBOSE(VB_IMPORTANT, "ZMClient got a mismatch between the number of frames and "
"the expected number of stringlist items in getFrameList()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient got a mismatch between the number of frames and "
"the expected number of stringlist items in getFrameList()");
return;
}

Expand Down Expand Up @@ -461,14 +471,15 @@ bool ZMClient::readData(unsigned char *data, int dataSize)
}
else if (sret < 0 && m_socket->error() != MSocketDevice::NoError)
{
VERBOSE(VB_GENERAL, QString("readData: Error, readBlock %1")
.arg(m_socket->errorToString()));
LOG(VB_GENERAL, LOG_ERR, QString("readData: Error, readBlock %1")
.arg(m_socket->errorToString()));
m_socket->close();
return false;
}
else if (!m_socket->isValid())
{
VERBOSE(VB_IMPORTANT, "readData: Error, socket went unconnected");
LOG(VB_GENERAL, LOG_ERR,
"readData: Error, socket went unconnected");
m_socket->close();
return false;
}
Expand All @@ -480,14 +491,15 @@ bool ZMClient::readData(unsigned char *data, int dataSize)
if ((elapsed - errmsgtime) > 10000)
{
errmsgtime = elapsed;
VERBOSE(VB_GENERAL, QString("m_socket->: Waiting for data: %1 %2")
.arg(read).arg(dataSize));
LOG(VB_GENERAL, LOG_ERR,
QString("m_socket->: Waiting for data: %1 %2")
.arg(read).arg(dataSize));
}
}

if (elapsed > 100000)
{
VERBOSE(VB_GENERAL, "Error, readData timeout (readBlock)");
LOG(VB_GENERAL, LOG_ERR, "Error, readData timeout (readBlock)");
return false;
}

Expand Down Expand Up @@ -520,7 +532,8 @@ void ZMClient::getEventFrame(int monitorID, int eventID, int frameNo, MythImage
unsigned char *data = new unsigned char[imageSize];
if (!readData(data, imageSize))
{
VERBOSE(VB_GENERAL, "ZMClient::getEventFrame(): Failed to get image data");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient::getEventFrame(): Failed to get image data");
delete [] data;
return;
}
Expand All @@ -532,7 +545,8 @@ void ZMClient::getEventFrame(int monitorID, int eventID, int frameNo, MythImage
// extract the image data and create a MythImage from it
if (!(*image)->loadFromData(data, imageSize, "JPEG"))
{
VERBOSE(VB_GENERAL, "ZMClient::getEventFrame(): Failed to load image from data");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient::getEventFrame(): Failed to load image from data");
}

delete [] data;
Expand All @@ -557,15 +571,17 @@ void ZMClient::getAnalyseFrame(int monitorID, int eventID, int frameNo, QImage &
unsigned char *data = new unsigned char[imageSize];
if (!readData(data, imageSize))
{
VERBOSE(VB_GENERAL, "ZMClient::getAnalyseFrame(): Failed to get image data");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient::getAnalyseFrame(): Failed to get image data");
image = QImage();
}
else
{
// extract the image data and create a QImage from it
if (!image.loadFromData(data, imageSize, "JPEG"))
{
VERBOSE(VB_GENERAL, "ZMClient::getAnalyseFrame(): Failed to load image from data");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient::getAnalyseFrame(): Failed to load image from data");
image = QImage();
}
}
Expand Down Expand Up @@ -598,7 +614,8 @@ int ZMClient::getLiveFrame(int monitorID, QString &status, unsigned char* buffer

if (bufferSize < imageSize)
{
VERBOSE(VB_GENERAL, "ZMClient::getLiveFrame(): Live frame buffer is too small!");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient::getLiveFrame(): Live frame buffer is too small!");
return 0;
}

Expand All @@ -608,7 +625,8 @@ int ZMClient::getLiveFrame(int monitorID, QString &status, unsigned char* buffer

if (!readData(buffer, imageSize))
{
VERBOSE(VB_GENERAL, "ZMClient::getLiveFrame(): Failed to get image data");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient::getLiveFrame(): Failed to get image data");
return 0;
}

Expand All @@ -627,7 +645,8 @@ void ZMClient::getCameraList(QStringList &cameraList)
int cameraCount = strList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "ZMClient received bad int in getCameraList()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient received bad int in getCameraList()");
return;
}

Expand All @@ -649,7 +668,8 @@ void ZMClient::getMonitorList(vector<Monitor*> *monitorList)
int monitorCount = strList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "ZMClient received bad int in getMonitorList()");
LOG(VB_GENERAL, LOG_ERR,
"ZMClient received bad int in getMonitorList()");
return;
}

Expand All @@ -674,11 +694,14 @@ void ZMClient::getMonitorList(vector<Monitor*> *monitorList)
pallete += (char) ((item->palette >> 8) & 0xff);
pallete += (char) ((item->palette >> 16) & 0xff);
pallete += (char) ((item->palette >> 24) & 0xff);
VERBOSE(VB_IMPORTANT, QString("Monitor: %1 (%2) is using palette: %3 (%4)")
.arg(item->name).arg(item->id).arg(item->palette).arg(pallete));
LOG(VB_GENERAL, LOG_NOTICE,
QString("Monitor: %1 (%2) is using palette: %3 (%4)")
.arg(item->name).arg(item->id).arg(item->palette)
.arg(pallete));
}
else
VERBOSE(VB_IMPORTANT, QString("Monitor: %1 (%2) is using palette: %3")
LOG(VB_GENERAL, LOG_NOTICE,
QString("Monitor: %1 (%2) is using palette: %3")
.arg(item->name).arg(item->id).arg(item->palette));
}
}
Expand Down
16 changes: 9 additions & 7 deletions mythplugins/mythzoneminder/mythzoneminder/zmconsole.cpp
Expand Up @@ -49,7 +49,7 @@ bool FunctionDialog::Create()

if (err)
{
VERBOSE(VB_IMPORTANT, "Cannot load screen 'functionpopup'");
LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'functionpopup'");
return false;
}

Expand Down Expand Up @@ -85,14 +85,16 @@ void FunctionDialog::setMonitorFunction(void)
QString function = m_functionList->GetValue();
bool enabled = (m_enabledCheck->GetCheckState() == MythUIStateType::Full);

VERBOSE(VB_GENERAL, "Monitor id : " + QString::number(m_monitor->id) +
" function change " + m_monitor->function + " -> " + function +
", enable value " + QString::number(m_monitor->enabled) + " -> " +
QString::number(enabled));
LOG(VB_GENERAL, LOG_INFO,
"Monitor id : " + QString::number(m_monitor->id) +
" function change " + m_monitor->function + " -> " + function +
", enable value " + QString::number(m_monitor->enabled) + " -> " +
QString::number(enabled));

if (m_monitor->function == function && m_monitor->enabled == enabled)
{
VERBOSE(VB_IMPORTANT, "Monitor Function/Enable values not changed so not updating.");
LOG(VB_GENERAL, LOG_WARNING,
"Monitor Function/Enable values not changed so not updating.");
emit haveResult(false);
Close();
return;
Expand Down Expand Up @@ -158,7 +160,7 @@ bool ZMConsole::Create(void)

if (err)
{
VERBOSE(VB_IMPORTANT, "Cannot load screen 'zmconsole'");
LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'zmconsole'");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythzoneminder/mythzoneminder/zmevents.cpp
Expand Up @@ -68,7 +68,7 @@ bool ZMEvents::Create(void)

if (err)
{
VERBOSE(VB_IMPORTANT, "Cannot load screen 'zmevents'");
LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'zmevents'");
return false;
}

Expand Down Expand Up @@ -424,7 +424,7 @@ void ZMEvents::setGridLayout(int layout)
}
else
{
VERBOSE(VB_IMPORTANT, QString("Theme is missing grid layout (%1).")
LOG(VB_GENERAL, LOG_ERR, QString("Theme is missing grid layout (%1).")
.arg(layoutName + "_eventlist"));
Close();
}
Expand Down
7 changes: 4 additions & 3 deletions mythplugins/mythzoneminder/mythzoneminder/zmliveplayer.cpp
Expand Up @@ -106,8 +106,9 @@ bool ZMLivePlayer::hideAll(void)
}
catch (const QString name)
{
VERBOSE(VB_IMPORTANT, QString("Theme is missing a critical theme element ('%1')")
.arg(name));
LOG(VB_GENERAL, LOG_ERR,
QString("Theme is missing a critical theme element ('%1')")
.arg(name));
return false;
}

Expand All @@ -119,7 +120,7 @@ bool ZMLivePlayer::initMonitorLayout()
// if we haven't got any monitors there's not much we can do so bail out!
if (m_monitors->size() == 0)
{
VERBOSE(VB_IMPORTANT, "Cannot find any monitors. Bailing out!");
LOG(VB_GENERAL, LOG_ERR, "Cannot find any monitors. Bailing out!");
ShowOkPopup(tr("Can't show live view.\nYou don't have any monitors defined!"));
return false;
}
Expand Down

0 comments on commit 1f33317

Please sign in to comment.