141 changes: 82 additions & 59 deletions mythtv/libs/libmythbase/httpcomms.cpp

Large diffs are not rendered by default.

67 changes: 34 additions & 33 deletions mythtv/libs/libmythbase/lcddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ LCD::LCD()
// Note that this does *not* include opening the socket and initiating
// communications with the LDCd daemon.

VERBOSE(VB_GENERAL|VB_EXTRA, LOC + "An LCD object now exists "
"(LCD() was called)");
LOG(VB_GENERAL, LOG_DEBUG, "An LCD object now exists (LCD() was called)");

connect(retryTimer, SIGNAL(timeout()), this, SLOT(restartConnection()));
connect(LEDTimer, SIGNAL(timeout()), this, SLOT(outputLEDs()));
Expand Down Expand Up @@ -122,7 +121,7 @@ bool LCD::connectToHost(const QString &lhostname, unsigned int lport)
{
QMutexLocker locker(&socketLock);

VERBOSE(VB_NETWORK|VB_EXTRA, QString(LOC + "connecting to host: %1 - port: %2")
LOG(VB_NETWORK, LOG_DEBUG, QString("connecting to host: %1 - port: %2")
.arg(lhostname).arg(lport));

// Open communications
Expand All @@ -143,11 +142,11 @@ bool LCD::connectToHost(const QString &lhostname, unsigned int lport)
if (myth_system("ps ch -C mythlcdserver -o pid > /dev/null", flags) == 1)
{
// we need to start the mythlcdserver
VERBOSE(VB_GENERAL, "Starting mythlcdserver");
LOG(VB_GENERAL, LOG_CRIT, "Starting mythlcdserver");

if (!startLCDServer())
{
VERBOSE(VB_IMPORTANT, "Failed start MythTV LCD Server");
LOG(VB_GENERAL, LOG_CRIT, "Failed start MythTV LCD Server");
return bConnected;
}

Expand All @@ -161,7 +160,7 @@ bool LCD::connectToHost(const QString &lhostname, unsigned int lport)
{
++count;

VERBOSE(VB_GENERAL, QString("Connecting to lcd server: "
LOG(VB_GENERAL, LOG_INFO, QString("Connecting to lcd server: "
"%1:%2 (try %3 of 10)").arg(hostname).arg(port)
.arg(count));

Expand Down Expand Up @@ -213,8 +212,8 @@ void LCD::sendToServer(const QString &someText)
// connection
retryTimer->setSingleShot(false);
retryTimer->start(10000);
VERBOSE(VB_IMPORTANT, "lcddevice: Connection to LCDServer died unexpectedly.\n\t\t\t"
"Trying to reconnect every 10 seconds. . .");
LOG(VB_GENERAL, LOG_CRIT, "Connection to LCDServer died unexpectedly. "
"Trying to reconnect every 10 seconds...");

bConnected = false;
return;
Expand All @@ -227,7 +226,8 @@ void LCD::sendToServer(const QString &someText)

if (bConnected)
{
VERBOSE(VB_NETWORK|VB_EXTRA, QString(LOC + "Sending to Server: %1").arg(someText));
LOG(VB_NETWORK, LOG_DEBUG,
QString(LOC + "Sending to Server: %1").arg(someText));

// Just stream the text out the socket
os << someText << "\n";
Expand Down Expand Up @@ -280,7 +280,7 @@ void LCD::readyRead(MythSocket *sock)

// Make debugging be less noisy
if (lineFromServer != "OK")
VERBOSE(VB_NETWORK|VB_EXTRA, QString(LOC + "Received from server: %1")
LOG(VB_NETWORK, LOG_DEBUG, QString("Received from server: %1")
.arg(lineFromServer));

aList = lineFromServer.split(' ');
Expand All @@ -290,32 +290,32 @@ void LCD::readyRead(MythSocket *sock)
// get lcd width & height
if (aList.count() != 3)
{
VERBOSE(VB_IMPORTANT, LOC + "received bad no. of arguments "
"in CONNECTED response from LCDServer");
LOG(VB_GENERAL, LOG_ERR, "received bad no. of arguments "
"in CONNECTED response from LCDServer");
}

bool bOK;
lcd_width = aList[1].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, LOC + "received bad int for width"
"in CONNECTED response from LCDServer");
LOG(VB_GENERAL, LOG_ERR, "received bad int for width"
"in CONNECTED response from LCDServer");
}

lcd_height = aList[2].toInt(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, LOC + "received bad int for height"
"in CONNECTED response from LCDServer");
LOG(VB_GENERAL, LOG_ERR, "received bad int for height"
"in CONNECTED response from LCDServer");
}

init();
}
else if (aList[0] == "HUH?")
{
VERBOSE(VB_IMPORTANT, LOC + "WARNING: Something is getting passed"
"to LCDServer that it does not understand");
VERBOSE(VB_IMPORTANT, QString(LOC + "last command: %1").arg( last_command ));
LOG(VB_GENERAL, LOG_ERR, "WARNING: Something is getting passed"
"to LCDServer that it does not understand");
LOG(VB_GENERAL, LOG_ERR, QString("last command: %1").arg(last_command));
}
else if (aList[0] == "KEY")
handleKeyPress(aList.last().trimmed());
Expand Down Expand Up @@ -380,15 +380,16 @@ void LCD::connectionFailed(MythSocket *sock)
{
QMutexLocker locker(&socketLock);
QString err = sock->errorToString();
VERBOSE(VB_IMPORTANT, QString("Could not connect to LCDServer: %1").arg(err));
LOG(VB_GENERAL, LOG_ERR, QString("Could not connect to LCDServer: %1")
.arg(err));
}

void LCD::stopAll()
{
if (!lcd_ready)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, "lcddevice: stopAll");
LOG(VB_GENERAL, LOG_DEBUG, "lcddevice: stopAll");

sendToServer("STOP_ALL");
}
Expand Down Expand Up @@ -570,7 +571,7 @@ void LCD::switchToTime()
if (!lcd_ready)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToTime");
LOG(VB_GENERAL, LOG_DEBUG, "switchToTime");

sendToServer("SWITCH_TO_TIME");
}
Expand All @@ -580,7 +581,7 @@ void LCD::switchToMusic(const QString &artist, const QString &album, const QStri
if (!lcd_ready || !lcd_showmusic)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToMusic");
LOG(VB_GENERAL, LOG_DEBUG, "switchToMusic");

sendToServer("SWITCH_TO_MUSIC " + quotedString(artist) + ' '
+ quotedString(album) + ' '
Expand All @@ -592,7 +593,7 @@ void LCD::switchToChannel(QString channum, QString title, QString subtitle)
if (!lcd_ready || !lcd_showchannel)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToChannel");
LOG(VB_GENERAL, LOG_DEBUG, "switchToChannel");

sendToServer("SWITCH_TO_CHANNEL " + quotedString(channum) + ' '
+ quotedString(title) + ' '
Expand All @@ -605,7 +606,7 @@ void LCD::switchToMenu(QList<LCDMenuItem> &menuItems, QString app_name,
if (!lcd_ready || !lcd_showmenu)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToMenu");
LOG(VB_GENERAL, LOG_DEBUG, "switchToMenu");

if (menuItems.isEmpty())
return;
Expand Down Expand Up @@ -646,7 +647,7 @@ void LCD::switchToGeneric(QList<LCDTextItem> &textItems)
if (!lcd_ready || !lcd_showgeneric)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToGeneric ");
LOG(VB_GENERAL, LOG_DEBUG, "switchToGeneric ");

if (textItems.isEmpty())
return;
Expand Down Expand Up @@ -684,7 +685,7 @@ void LCD::switchToVolume(QString app_name)
if (!lcd_ready || !lcd_showvolume)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToVolume ");
LOG(VB_GENERAL, LOG_DEBUG, "switchToVolume ");

sendToServer("SWITCH_TO_VOLUME " + quotedString(app_name));
}
Expand All @@ -694,7 +695,7 @@ void LCD::switchToNothing()
if (!lcd_ready)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToNothing");
LOG(VB_GENERAL, LOG_DEBUG, "switchToNothing");

sendToServer("SWITCH_TO_NOTHING");
}
Expand All @@ -703,7 +704,7 @@ void LCD::shutdown()
{
QMutexLocker locker(&socketLock);

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "shutdown");
LOG(VB_GENERAL, LOG_DEBUG, "shutdown");

if (socket)
socket->close();
Expand All @@ -719,7 +720,7 @@ void LCD::resetServer()
if (!lcd_ready)
return;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "RESET");
LOG(VB_GENERAL, LOG_DEBUG, "RESET");

sendToServer("RESET");
}
Expand All @@ -728,8 +729,8 @@ LCD::~LCD()
{
m_lcd = NULL;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "An LCD device is being snuffed out of "
"existence (~LCD() was called)");
LOG(VB_GENERAL, LOG_DEBUG, "An LCD device is being snuffed out of "
"existence (~LCD() was called)");

if (socket)
{
Expand All @@ -744,7 +745,7 @@ void LCD::setLevels(int numbLevels, float *values)
numbLevels = numbLevels;
values = values;

VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "setLevels");
LOG(VB_GENERAL, LOG_DEBUG, "setLevels");
}

QString LCD::quotedString(const QString &s)
Expand Down
42 changes: 22 additions & 20 deletions mythtv/libs/libmythbase/msocketdevice_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void MSocketDevice::close()
return;
setOpenMode(NotOpen);
::close( fd );
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
QString("MSocketDevice::close: Closed socket %1").arg(fd));
fd = -1;
fetchConnectionParameters();
Expand Down Expand Up @@ -246,9 +246,8 @@ bool MSocketDevice::blocking() const
*/
void MSocketDevice::setBlocking( bool enable )
{
VERBOSE(VB_SOCKET|VB_EXTRA,
QString("MSocketDevice::setBlocking(%1)")
.arg((enable) ? "true":"false"));
LOG(VB_SOCKET, LOG_DEBUG, QString("MSocketDevice::setBlocking(%1)")
.arg((enable) ? "true":"false"));

if ( !isValid() )
return;
Expand Down Expand Up @@ -395,16 +394,19 @@ bool MSocketDevice::connect( const QHostAddress &addr, quint16 port )
#if !defined(QT_NO_IPV6)
if ( addr.protocol() == QAbstractSocket::IPv6Protocol ) {
setProtocol(IPv6);
VERBOSE(VB_SOCKET, "MSocketDevice::connect: setting Protocol to IPv6");
LOG(VB_SOCKET, LOG_INFO,
"MSocketDevice::connect: setting Protocol to IPv6");
}
else
#endif
if ( addr.protocol() == QAbstractSocket::IPv4Protocol ) {
setProtocol(IPv4);
VERBOSE(VB_SOCKET, "MSocketDevice::connect: setting Protocol to IPv4");
LOG(VB_SOCKET, LOG_INFO,
"MSocketDevice::connect: setting Protocol to IPv4");
}

VERBOSE(VB_SOCKET, "MSocketDevice::connect: attempting to create new socket");
LOG(VB_SOCKET, LOG_INFO,
"MSocketDevice::connect: attempting to create new socket");
MSocketDevice::setSocket( createNewSocket(), t);

// If still not valid, give up.
Expand Down Expand Up @@ -763,22 +765,22 @@ qint64 MSocketDevice::readData( char *data, qint64 maxlen )
return 0;

if ( data == 0 ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::readBlock: Null pointer error");
return -1;
}
if ( !isValid() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::readBlock: Invalid socket");
return -1;
}
if ( !isOpen() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::readBlock: Device is not open");
return -1;
}
if ( !isReadable() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::readBlock: Read operation not permitted");
return -1;
}
Expand Down Expand Up @@ -859,22 +861,22 @@ qint64 MSocketDevice::writeData( const char *data, qint64 len )
return 0;

if ( data == 0 ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::writeBlock: Null pointer error");
return -1;
}
if ( !isValid() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::writeBlock: Invalid socket");
return -1;
}
if ( !isOpen() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::writeBlock: Device is not open");
return -1;
}
if ( !isWritable() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::writeBlock: Write operation not permitted");
return -1;
}
Expand Down Expand Up @@ -946,28 +948,28 @@ qint64 MSocketDevice::writeBlock( const char * data, quint64 len,
return 0;

if ( t != Datagram ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::sendBlock: Not datagram");
return -1; // for now - later we can do t/tcp
}

if ( data == 0 ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::sendBlock: Null pointer error");
return -1;
}
if ( !isValid() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::sendBlock: Invalid socket");
return -1;
}
if ( !isOpen() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::sendBlock: Device is not open");
return -1;
}
if ( !isWritable() ) {
VERBOSE(VB_SOCKET|VB_EXTRA,
LOG(VB_SOCKET, LOG_DEBUG,
"MSocketDevice::sendBlock: Write operation not permitted");
return -1;
}
Expand Down
9 changes: 6 additions & 3 deletions mythtv/libs/libmythbase/msocketdevice_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,19 @@ bool MSocketDevice::connect( const QHostAddress &addr, quint16 port )
#if !defined(QT_NO_IPV6)
if ( addr.protocol() == QAbstractSocket::IPv6Protocol ) {
setProtocol(IPv6);
VERBOSE(VB_SOCKET, "MSocketDevice::connect: setting Protocol to IPv6");
LOG(VB_SOCKET, LOG_INFO,
"MSocketDevice::connect: setting Protocol to IPv6");
}
else
#endif
if ( addr.protocol() == QAbstractSocket::IPv4Protocol ) {
setProtocol(IPv4);
VERBOSE(VB_SOCKET, "MSocketDevice::connect: setting Protocol to IPv4");
LOG(VB_SOCKET, LOG_INFO,
"MSocketDevice::connect: setting Protocol to IPv4");
}

VERBOSE(VB_SOCKET, "MSocketDevice::connect: attempting to create new socket");
LOG(VB_SOCKET, LOG_INFO,
"MSocketDevice::connect: attempting to create new socket");
MSocketDevice::setSocket( createNewSocket(), t);

// If still not valid, give up.
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythbase/mythbaseutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static inline void setup_pipe(int mypipe[2], long myflags[2])
int pipe_ret = pipe(mypipe);
if (pipe_ret < 0)
{
VERBOSE(VB_IMPORTANT, "Failed to open pipes" + ENO);
LOG(VB_GENERAL, LOG_CRIT, "Failed to open pipes" + ENO);
mypipe[0] = mypipe[1] = -1;
}
else
Expand All @@ -31,11 +31,12 @@ static inline void setup_pipe(int mypipe[2], long myflags[2])
{
int ret = fcntl(mypipe[0], F_SETFL, flags|O_NONBLOCK);
if (ret < 0)
VERBOSE(VB_IMPORTANT, QString("Set pipe flags error") + ENO);
LOG(VB_GENERAL, LOG_CRIT,
QString("Set pipe flags error") + ENO);
}
else
{
VERBOSE(VB_IMPORTANT, QString("Get pipe flags error") + ENO);
LOG(VB_GENERAL, LOG_CRIT, QString("Get pipe flags error") + ENO);
}

for (uint i = 0; i < 2; i++)
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythbase/mythcdrom-darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ void MythCDROMDarwin::setSpeed(const char *device, int speed)
fd = open(raw.toLocal8Bit().constData(), O_RDONLY | O_NONBLOCK);
if (fd == -1)
{
VERBOSE(VB_MEDIA, LOC_ERR + "setSpeed() can't open drive " + raw);
LOG(VB_MEDIA, LOG_ERR, "setSpeed() can't open drive " + raw);
return;
}

if (ioctl(fd, DKIOCCDSETSPEED, &spd) == -1 &&
ioctl(fd, DKIOCDVDSETSPEED, &spd) == -1)
{
VERBOSE(VB_MEDIA, (LOC_ERR + "setSpeed() failed: ") + strerror(errno));
LOG(VB_MEDIA, LOG_ERR, "setSpeed() failed: " + ENO);
close(fd);
return;
}
VERBOSE(VB_MEDIA, LOC + ":setSpeed() - CD/DVD Speed Set to "
+ QString::number(spd));
LOG(VB_MEDIA, LOG_INFO, ":setSpeed() - CD/DVD Speed Set to " +
QString::number(spd));
close(fd);
}
8 changes: 5 additions & 3 deletions mythtv/libs/libmythbase/mythcdrom-freebsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ MythMediaError MythCDROMFreeBSD::unlock()
{
if (isDeviceOpen() || openDevice())
{
//VERBOSE(VB_GENERAL, "Unlocking CDROM door");
#if 0
LOG(VB_GENERAL, LOG_DEBUG, "Unlocking CDROM door");
#endif
ioctl(m_DeviceHandle, CDIOCALLOW);
}
else
{
VERBOSE(VB_GENERAL, "Failed to open device, CDROM try will remain "
"locked.");
LOG(VB_GENERAL, LOG_INFO, "Failed to open device, CDROM try will "
"remain locked.");
}

return MythMediaDevice::unlock();
Expand Down
131 changes: 62 additions & 69 deletions mythtv/libs/libmythbase/mythcdrom-linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int MythCDROMLinux::driveStatus()

if (drive_status == -1) // Very unlikely, but we should check
{
VERBOSE(VB_MEDIA, LOC + ":driveStatus() - ioctl() failed: " + ENO);
LOG(VB_MEDIA, LOG_INFO, "driveStatus() - ioctl() failed: " + ENO);
return CDS_NO_INFO;
}

Expand Down Expand Up @@ -200,9 +200,8 @@ bool MythCDROMLinux::hasWritableMedia()

if (ioctl(m_DeviceHandle, CDROM_SEND_PACKET, &cgc) < 0)
{
VERBOSE(VB_MEDIA,
LOC + ":hasWritableMedia() - failed to send packet to "
+ m_DevicePath);
LOG(VB_MEDIA, LOG_ERR,
"hasWritableMedia() - failed to send packet to " + m_DevicePath);
return false;
}

Expand Down Expand Up @@ -260,29 +259,25 @@ int MythCDROMLinux::SCSIstatus()
|| es->nea // drive does not support request
|| (es->notification_class != 0x4)) // notification class mismatch
{
VERBOSE(VB_MEDIA,
LOC + ":SCSIstatus() - failed to send SCSI packet to "
+ m_DevicePath);
LOG(VB_MEDIA, LOG_ERR,
"SCSIstatus() - failed to send SCSI packet to " + m_DevicePath);
return CDS_TRAY_OPEN;
}

if (es->media_present)
{
VERBOSE(VB_MEDIA+VB_EXTRA,
LOC + ":SCSIstatus() - ioctl() said tray was open,"
"but drive is actually closed with a disc");
LOG(VB_MEDIA, LOG_DEBUG, "SCSIstatus() - ioctl() said tray was open, "
"but drive is actually closed with a disc");
return CDS_DISC_OK;
}
else if (es->door_open)
{
VERBOSE(VB_MEDIA+VB_EXTRA,
LOC + ":SCSIstatus() - tray is definitely open");
LOG(VB_MEDIA, LOG_DEBUG, "SCSIstatus() - tray is definitely open");
return CDS_TRAY_OPEN;
}

VERBOSE(VB_MEDIA+VB_EXTRA,
LOC + ":SCSIstatus() - ioctl() said tray was open,"
" but drive is actually closed with no disc");
LOG(VB_MEDIA, LOG_DEBUG, "SCSIstatus() - ioctl() said tray was open, "
"but drive is actually closed with no disc");
return CDS_NO_DISC;
}

Expand Down Expand Up @@ -332,14 +327,14 @@ MythMediaError MythCDROMLinux::testMedia()
{
if (!openDevice())
{
VERBOSE(VB_MEDIA+VB_EXTRA, LOC + ":testMedia - failed to open '"
+ m_DevicePath + "' : " +ENO);
LOG(VB_MEDIA, LOG_DEBUG, "testMedia - failed to open '" +
m_DevicePath + "' : " +ENO);
if (errno == EBUSY)
return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED;
else
return MEDIAERR_FAILED;
}
VERBOSE(VB_MEDIA+VB_EXTRA, LOC + ":testMedia - Opened device");
LOG(VB_MEDIA, LOG_DEBUG, "testMedia - Opened device");
OpenedHere = true;
}

Expand All @@ -353,9 +348,8 @@ MythMediaError MythCDROMLinux::testMedia()

if (Stat == -1)
{
VERBOSE(VB_MEDIA+VB_EXTRA,
LOC + ":testMedia - Failed to get drive status of '"
+ m_DevicePath + "' : " + ENO);
LOG(VB_MEDIA, LOG_DEBUG, "testMedia - Failed to get drive status of '" +
m_DevicePath + "' : " + ENO);
return MEDIAERR_FAILED;
}

Expand All @@ -374,9 +368,9 @@ MythMediaStatus MythCDROMLinux::checkMedia()

if (!OpenedHere)
{
VERBOSE(VB_MEDIA, LOC + ":checkMedia() - cannot open device '"
+ m_DevicePath + "' : "
+ ENO + "- returning UNKNOWN");
LOG(VB_MEDIA, LOG_ERR, "checkMedia() - cannot open device '" +
m_DevicePath + "' : " +
ENO + "- returning UNKNOWN");
m_MediaType = MEDIATYPE_UNKNOWN;
return setStatus(MEDIASTAT_UNKNOWN, false);
}
Expand All @@ -385,12 +379,12 @@ MythMediaStatus MythCDROMLinux::checkMedia()
switch (driveStatus())
{
case CDS_DISC_OK:
VERBOSE(VB_MEDIA|VB_EXTRA, m_DevicePath + " Disk OK, type = "
+ MediaTypeString(m_MediaType) );
LOG(VB_MEDIA, LOG_DEBUG, m_DevicePath + " Disk OK, type = " +
MediaTypeString(m_MediaType) );
// further checking is required
break;
case CDS_TRAY_OPEN:
VERBOSE(VB_MEDIA|VB_EXTRA, m_DevicePath + " Tray open or no disc");
LOG(VB_MEDIA, LOG_DEBUG, m_DevicePath + " Tray open or no disc");
// First, send a message to the
// plugins to forget the current media type
setStatus(MEDIASTAT_OPEN, OpenedHere);
Expand All @@ -399,25 +393,26 @@ MythMediaStatus MythCDROMLinux::checkMedia()
return MEDIASTAT_OPEN;
break;
case CDS_NO_DISC:
VERBOSE(VB_MEDIA|VB_EXTRA, m_DevicePath + " No disc");
LOG(VB_MEDIA, LOG_DEBUG, m_DevicePath + " No disc");
m_MediaType = MEDIATYPE_UNKNOWN;
return setStatus(MEDIASTAT_NODISK, OpenedHere);
break;
case CDS_NO_INFO:
case CDS_DRIVE_NOT_READY:
VERBOSE(VB_MEDIA|VB_EXTRA, m_DevicePath + " No info or drive not ready");
LOG(VB_MEDIA, LOG_DEBUG, m_DevicePath +
" No info or drive not ready");
m_MediaType = MEDIATYPE_UNKNOWN;
return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
default:
VERBOSE(VB_IMPORTANT, "Failed to get drive status of "
+ m_DevicePath + " : " + ENO);
LOG(VB_GENERAL, LOG_CRIT, "Failed to get drive status of " +
m_DevicePath + " : " + ENO);
m_MediaType = MEDIATYPE_UNKNOWN;
return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
}

if (mediaChanged())
{
VERBOSE(VB_MEDIA, m_DevicePath + " Media changed");
LOG(VB_MEDIA, LOG_INFO, m_DevicePath + " Media changed");
// Regardless of the actual status lie here and say
// it's open for now, so we can cover the case of a missed open.
return setStatus(MEDIASTAT_OPEN, OpenedHere);
Expand All @@ -426,7 +421,7 @@ MythMediaStatus MythCDROMLinux::checkMedia()

if (isUsable())
{
VERBOSE(VB_MEDIA+VB_EXTRA, "Disc useable, media unchanged. All good!");
LOG(VB_MEDIA, LOG_DEBUG, "Disc useable, media unchanged. All good!");
if (OpenedHere)
closeDevice();
return MEDIASTAT_USEABLE;
Expand All @@ -435,7 +430,7 @@ MythMediaStatus MythCDROMLinux::checkMedia()
// If we have tried to mount and failed, don't keep trying
if (m_Status == MEDIASTAT_ERROR)
{
VERBOSE(VB_MEDIA+VB_EXTRA, "Disc is unmountable?");
LOG(VB_MEDIA, LOG_DEBUG, "Disc is unmountable?");
if (OpenedHere)
closeDevice();
return m_Status;
Expand All @@ -444,7 +439,7 @@ MythMediaStatus MythCDROMLinux::checkMedia()
if ((m_Status == MEDIASTAT_OPEN) ||
(m_Status == MEDIASTAT_UNKNOWN))
{
VERBOSE(VB_MEDIA, m_DevicePath + " Current status " +
LOG(VB_MEDIA, LOG_INFO, m_DevicePath + " Current status " +
MythMediaDevice::MediaStatusStrings[m_Status]);
int type = ioctl(m_DeviceHandle, CDROM_DISC_STATUS, CDSL_CURRENT);
switch (type)
Expand All @@ -453,7 +448,7 @@ MythMediaStatus MythCDROMLinux::checkMedia()
case CDS_DATA_2:
{
m_MediaType = MEDIATYPE_DATA;
VERBOSE(VB_MEDIA, "Found a data disk");
LOG(VB_MEDIA, LOG_INFO, "Found a data disk");

//grab information from iso9660 (& udf)
off_t sr = lseek(m_DeviceHandle,
Expand Down Expand Up @@ -486,7 +481,8 @@ MythMediaStatus MythCDROMLinux::checkMedia()
QDateTime::currentDateTime().toString(Qt::ISODate);
}

VERBOSE(VB_MEDIA, QString("Volume ID: %1").arg(m_VolumeID));
LOG(VB_MEDIA, LOG_INFO,
QString("Volume ID: %1").arg(m_VolumeID));
#ifdef USING_LIBUDF
// Check for a DVD/BD disk by reading the UDF root dir.
// This allows DVD's to play immediately upon insertion without
Expand Down Expand Up @@ -538,13 +534,13 @@ MythMediaStatus MythCDROMLinux::checkMedia()
break;
}
case CDS_AUDIO:
VERBOSE(VB_MEDIA, "found an audio disk");
LOG(VB_MEDIA, LOG_DEBUG, "found an audio disk");
m_MediaType = MEDIATYPE_AUDIO;
return setStatus(MEDIASTAT_USEABLE, OpenedHere);
break;
case CDS_MIXED:
m_MediaType = MEDIATYPE_MIXED;
VERBOSE(VB_MEDIA, "found a mixed CD");
LOG(VB_MEDIA, LOG_DEBUG, "found a mixed CD");
// Note: Mixed mode CDs require an explixit mount call
// since we'll usually want the audio portion.
// undefine ASSUME_WANT_AUDIO to change this behavior.
Expand All @@ -569,17 +565,17 @@ MythMediaStatus MythCDROMLinux::checkMedia()
case CDS_NO_DISC:
if (hasWritableMedia())
{
VERBOSE(VB_MEDIA, "found a blank or writable disk");
LOG(VB_MEDIA, LOG_DEBUG, "found a blank or writable disk");
return setStatus(MEDIASTAT_UNFORMATTED, OpenedHere);
}

VERBOSE(VB_MEDIA, "found no disk");
LOG(VB_MEDIA, LOG_DEBUG, "found no disk");
m_MediaType = MEDIATYPE_UNKNOWN;
return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
break;
default:
VERBOSE(VB_MEDIA, "found unknown disk type: "
+ QString().setNum(type));
LOG(VB_MEDIA, LOG_DEBUG, "found unknown disk type: " +
QString::number(type));
m_MediaType = MEDIATYPE_UNKNOWN;
return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
}
Expand All @@ -593,9 +589,8 @@ MythMediaStatus MythCDROMLinux::checkMedia()
if (OpenedHere)
closeDevice();

VERBOSE(VB_MEDIA+VB_EXTRA,
QString("Returning ")
+ MythMediaDevice::MediaStatusStrings[m_Status]);
LOG(VB_MEDIA, LOG_DEBUG, QString("Returning %1")
.arg(MythMediaDevice::MediaStatusStrings[m_Status]));
return m_Status;
}

Expand All @@ -612,13 +607,13 @@ MythMediaError MythCDROMLinux::unlock()
{
if (isDeviceOpen() || openDevice())
{
VERBOSE(VB_MEDIA+VB_EXTRA, LOC + ":unlock - Unlocking CDROM door");
LOG(VB_MEDIA, LOG_DEBUG, "unlock - Unlocking CDROM door");
ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 0);
}
else
{
VERBOSE(VB_GENERAL, "Failed to open device, CDROM try will remain "
"locked.");
LOG(VB_GENERAL, LOG_INFO, "Failed to open device, CDROM try will "
"remain locked.");
}

return MythMediaDevice::unlock();
Expand All @@ -631,19 +626,19 @@ bool MythCDROMLinux::isSameDevice(const QString &path)

if (stat(path.toLocal8Bit().constData(), &sb) < 0)
{
VERBOSE(VB_IMPORTANT, LOC + ":isSameDevice() -- " +
QString("Failed to stat '%1'")
.arg(path) + ENO);
LOG(VB_GENERAL, LOG_CRIT,
"isSameDevice() -- " + QString("Failed to stat '%1'").arg(path) +
ENO);
return false;
}
new_rdev = sb.st_rdev;

// Check against m_DevicePath...
if (stat(m_DevicePath.toLocal8Bit().constData(), &sb) < 0)
{
VERBOSE(VB_IMPORTANT, LOC + ":isSameDevice() -- " +
QString("Failed to stat '%1'")
.arg(m_DevicePath) + ENO);
LOG(VB_GENERAL, LOG_CRIT, "isSameDevice() -- " +
QString("Failed to stat '%1'")
.arg(m_DevicePath) + ENO);
return false;
}
return (sb.st_rdev == new_rdev);
Expand Down Expand Up @@ -676,23 +671,22 @@ void MythCDROMLinux::setSpeed(const char *device, int speed)

if ((fd = open(device, O_RDWR | O_NONBLOCK)) == -1)
{
VERBOSE(VB_MEDIA, LOC_ERR + "Changing CD/DVD speed needs write access");
LOG(VB_MEDIA, LOG_ERR, "Changing CD/DVD speed needs write access");
return;
}

if (fstat(fd, &st) == -1)
{
close(fd);
VERBOSE(VB_MEDIA, LOC_ERR +
QString("setSpeed() Failed. device %1 not found")
.arg(device));
LOG(VB_MEDIA, LOG_ERR,
QString("setSpeed() Failed. device %1 not found") .arg(device));
return;
}

if (!S_ISBLK(st.st_mode))
{
close(fd);
VERBOSE(VB_MEDIA, LOC_ERR + "setSpeed() Failed. Not a block device");
LOG(VB_MEDIA, LOG_ERR, "setSpeed() Failed. Not a block device");
return;
}

Expand All @@ -708,7 +702,7 @@ void MythCDROMLinux::setSpeed(const char *device, int speed)
{
rate = 0;
buffer[0] = 4;
VERBOSE(VB_MEDIA, LOC + ":setSpeed() - Restored CD/DVD Speed");
LOG(VB_MEDIA, LOG_INFO, "setSpeed() - Restored CD/DVD Speed");
break;
}
default:
Expand All @@ -718,9 +712,9 @@ void MythCDROMLinux::setSpeed(const char *device, int speed)

rate = (speed > 0 && speed < 100) ? speed * 177 : speed;

VERBOSE(VB_MEDIA,
(LOC + ":setSpeed() - Limiting CD/DVD Speed to %1KB/s")
.arg(rate));
LOG(VB_MEDIA, LOG_INFO,
QString("setSpeed() - Limiting CD/DVD Speed to %1KB/s")
.arg(rate));
break;
}
}
Expand Down Expand Up @@ -754,18 +748,17 @@ void MythCDROMLinux::setSpeed(const char *device, int speed)

if (ioctl(fd, SG_IO, &sghdr) < 0)
{
VERBOSE(VB_MEDIA, LOC_ERR + "Limit CD/DVD Speed Failed");
LOG(VB_MEDIA, LOG_ERR, "Limit CD/DVD Speed Failed");
}
else
{
// On my system (2.6.18 + ide-cd), SG_IO succeeds without doing anything,
// On my system (2.6.18+ide-cd), SG_IO succeeds without doing anything,
// while CDROM_SELECT_SPEED works...
if (ioctl(fd, CDROM_SELECT_SPEED, speed) < 0)
{
VERBOSE(VB_MEDIA, LOC_ERR +
"Limit CD/DVD CDROM_SELECT_SPEED Failed");
LOG(VB_MEDIA, LOG_ERR, "Limit CD/DVD CDROM_SELECT_SPEED Failed");
}
VERBOSE(VB_MEDIA, LOC + ":setSpeed() - CD/DVD Speed Set Successful");
LOG(VB_MEDIA, LOG_INFO, "setSpeed() - CD/DVD Speed Set Successful");
}

close(fd);
Expand Down
23 changes: 12 additions & 11 deletions mythtv/libs/libmythbase/mythcdrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void MythCDROM::onDeviceMounted()
{
if (!QDir(m_MountPath).exists())
{
VERBOSE(VB_IMPORTANT, QString("Mountpoint '%1' doesn't exist")
.arg(m_MountPath));
LOG(VB_GENERAL, LOG_ERR, QString("Mountpoint '%1' doesn't exist")
.arg(m_MountPath));
m_MediaType = MEDIATYPE_UNKNOWN;
m_Status = MEDIASTAT_ERROR;
return;
Expand All @@ -74,39 +74,39 @@ void MythCDROM::onDeviceMounted()

if (dvd.exists())
{
VERBOSE(VB_MEDIA, "Probable DVD detected.");
LOG(VB_MEDIA, LOG_INFO, "Probable DVD detected.");
m_MediaType = MEDIATYPE_DVD;
m_Status = MEDIASTAT_USEABLE;
}
if (bd.exists())
{
VERBOSE(VB_MEDIA, "Probable Blu-ray detected.");
LOG(VB_MEDIA, LOG_INFO, "Probable Blu-ray detected.");
m_MediaType = MEDIATYPE_BD;
m_Status = MEDIASTAT_USEABLE;
}
else if (audio.exists())
{
VERBOSE(VB_MEDIA, "Probable Audio CD detected.");
LOG(VB_MEDIA, LOG_INFO, "Probable Audio CD detected.");
m_MediaType = MEDIATYPE_AUDIO;
m_Status = MEDIASTAT_USEABLE;
}
else if (vcd.exists() || svcd.exists())
{
VERBOSE(VB_MEDIA, "Probable VCD/SVCD detected.");
LOG(VB_MEDIA, LOG_INFO, "Probable VCD/SVCD detected.");
m_MediaType = MEDIATYPE_VCD;
m_Status = MEDIASTAT_USEABLE;
}
else if (bad_dvd.exists())
VERBOSE(VB_IMPORTANT,
"DVD incorrectly mounted? (ISO9660 instead of UDF)");
LOG(VB_GENERAL, LOG_ERR,
"DVD incorrectly mounted? (ISO9660 instead of UDF)");
else
{
VERBOSE(VB_GENERAL,
LOG(VB_GENERAL, LOG_ERR,
QString("CD/DVD '%1' contained none of\n").arg(m_MountPath) +
QString("\t\t\t%1, %2, %3 or %4").arg(PATHTO_DVD_DETECT)
.arg(PATHTO_AUDIO_DETECT).arg(PATHTO_VCD_DETECT)
.arg(PATHTO_SVCD_DETECT));
VERBOSE(VB_GENERAL, "Searching CD statistically - file by file!");
LOG(VB_GENERAL, LOG_INFO, "Searching CD statistically - file by file!");
}

// If not DVD/AudioCD/VCD/SVCD, use parent's more generic version
Expand All @@ -126,6 +126,7 @@ void MythCDROM::onDeviceMounted()

void MythCDROM::setSpeed(const char *devicePath, int speed)
{
VERBOSE(VB_MEDIA, QString("SetSpeed(%1,%2) - not implemented on this OS.")
LOG(VB_MEDIA, LOG_INFO,
QString("SetSpeed(%1,%2) - not implemented on this OS.")
.arg(devicePath).arg(speed));
}
119 changes: 61 additions & 58 deletions mythtv/libs/libmythbase/mythcorecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool MythCoreContextPrivate::WaitForWOL(int timeout_in_ms)
int timeout_remaining = timeout_in_ms;
while (m_WOLInProgress && (timeout_remaining > 0))
{
VERBOSE(VB_GENERAL, LOC + "Wake-On-LAN in progress, waiting...");
LOG(VB_GENERAL, LOG_INFO, "Wake-On-LAN in progress, waiting...");

int max_wait = min(1000, timeout_remaining);
m_WOLInProgressWaitCondition.wait(
Expand All @@ -148,22 +148,22 @@ bool MythCoreContext::Init(void)
{
if (!d)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Init() Out-of-memory");
LOG(VB_GENERAL, LOG_EMERG, "Init() Out-of-memory");
return false;
}

if (d->m_appBinaryVersion != MYTH_BINARY_VERSION)
{
VERBOSE(VB_GENERAL, QString("Application binary version (%1) does not "
"match libraries (%2)")
.arg(d->m_appBinaryVersion)
.arg(MYTH_BINARY_VERSION));
LOG(VB_GENERAL, LOG_CRIT,
QString("Application binary version (%1) does not "
"match libraries (%2)")
.arg(d->m_appBinaryVersion) .arg(MYTH_BINARY_VERSION));

QString warning = QObject::tr(
"This application is not compatible "
"with the installed MythTV libraries. "
"Please recompile after a make distclean");
VERBOSE(VB_IMPORTANT, warning);
LOG(VB_GENERAL, LOG_WARNING, warning);

return false;
}
Expand Down Expand Up @@ -209,20 +209,20 @@ bool MythCoreContext::SetupCommandSocket(MythSocket *serverSock,

if (!serverSock->writeStringList(strlist))
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Connecting server socket to "
"master backend, socket write failed");
LOG(VB_GENERAL, LOG_ERR, "Connecting server socket to "
"master backend, socket write failed");
return false;
}

if (!serverSock->readStringList(strlist, true) || strlist.empty() ||
(strlist[0] == "ERROR"))
{
if (!strlist.empty())
VERBOSE(VB_IMPORTANT, LOC_ERR + "Problem connecting "
"server socket to master backend");
LOG(VB_GENERAL, LOG_ERR, "Problem connecting "
"server socket to master backend");
else
VERBOSE(VB_IMPORTANT, LOC_ERR + "Timeout connecting "
"server socket to master backend");
LOG(VB_GENERAL, LOG_ERR, "Timeout connecting "
"server socket to master backend");
return false;
}

Expand All @@ -237,7 +237,7 @@ bool MythCoreContext::ConnectToMasterServer(bool blockingClient)
{
// Should never get here unless there is a bug in the code somewhere.
// If this happens, it can cause endless event loops.
VERBOSE(VB_IMPORTANT, "ERROR: Master backend tried to connect back "
LOG(VB_GENERAL, LOG_ERR, "ERROR: Master backend tried to connect back "
"to itself!");
return false;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ MythSocket *MythCoreContext::ConnectCommandSocket(
bool proto_mismatch = false;
for (int cnt = 1; cnt <= maxConnTry; cnt++)
{
VERBOSE(VB_GENERAL, LOC +
LOG(VB_GENERAL, LOG_INFO,
QString("Connecting to backend server: %1:%2 (try %3 of %4)")
.arg(hostname).arg(port).arg(cnt).arg(maxConnTry));

Expand Down Expand Up @@ -375,7 +375,7 @@ MythSocket *MythCoreContext::ConnectCommandSocket(

if (!m_serverSock && !proto_mismatch)
{
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_ERR,
"Connection to master server timed out.\n\t\t\t"
"Either the server is down or the master server settings"
"\n\t\t\t"
Expand Down Expand Up @@ -404,8 +404,8 @@ MythSocket *MythCoreContext::ConnectEventSocket(const QString &hostname,
// this one won't need multiple retries to work...
if (!m_eventSock->connect(hostname, port))
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to connect event "
"socket to master backend");
LOG(VB_GENERAL, LOG_ERR, "Failed to connect event "
"socket to master backend");
m_eventSock->DownRef();
m_eventSock = NULL;
return NULL;
Expand All @@ -421,11 +421,11 @@ MythSocket *MythCoreContext::ConnectEventSocket(const QString &hostname,
(strlist[0] == "ERROR"))
{
if (!strlist.empty())
VERBOSE(VB_IMPORTANT, LOC_ERR + "Problem connecting "
"event socket to master backend");
LOG(VB_GENERAL, LOG_ERR, "Problem connecting "
"event socket to master backend");
else
VERBOSE(VB_IMPORTANT, LOC_ERR + "Timeout connecting "
"event socket to master backend");
LOG(VB_GENERAL, LOG_ERR, "Timeout connecting "
"event socket to master backend");

m_eventSock->DownRef();
m_eventSock->Unlock();
Expand Down Expand Up @@ -603,7 +603,9 @@ QString MythCoreContext::GenMythURL(QString host, int port, QString path, QStrin

ret = QString("myth://%1%2%3%4%5").arg(m_storageGroup).arg(m_host).arg(m_port).arg(seperator).arg(path);

//VERBOSE(VB_GENERAL, LOC + QString("GenMythURL returning %1").arg(ret));
#if 0
LOG(VB_GENERAL, LOG_DEBUG, QString("GenMythURL returning %1").arg(ret));
#endif

return ret;
}
Expand Down Expand Up @@ -793,7 +795,7 @@ bool MythCoreContext::SendReceiveStringList(QStringList &strlist,
msg += (i?",":"") + strlist[i];
msg += (strlist.size() > 2) ? "...)" : ")";
msg += " called from UI thread";
VERBOSE(VB_GENERAL|VB_EXTRA, msg);
LOG(VB_GENERAL, LOG_DEBUG, msg);
}

QString query_type = "UNKNOWN";
Expand All @@ -818,7 +820,8 @@ bool MythCoreContext::SendReceiveStringList(QStringList &strlist,

if (!ok)
{
VERBOSE(VB_IMPORTANT, QString("Connection to backend server lost"));
LOG(VB_GENERAL, LOG_CRIT,
QString("Connection to backend server lost"));
d->m_serverSock->DownRef();
d->m_serverSock = NULL;

Expand All @@ -842,7 +845,7 @@ bool MythCoreContext::SendReceiveStringList(QStringList &strlist,
while (ok && strlist[0] == "BACKEND_MESSAGE")
{
// oops, not for us
VERBOSE(VB_IMPORTANT, "SRSL you shouldn't see this!!");
LOG(VB_GENERAL, LOG_EMERG, "SRSL you shouldn't see this!!");
QString message = strlist[1];
strlist.pop_front(); strlist.pop_front();

Expand All @@ -860,8 +863,8 @@ bool MythCoreContext::SendReceiveStringList(QStringList &strlist,
d->m_serverSock = NULL;
}

VERBOSE(VB_IMPORTANT,
QString("Reconnection to backend server failed"));
LOG(VB_GENERAL, LOG_CRIT,
QString("Reconnection to backend server failed"));

QCoreApplication::postEvent(d->m_GUIcontext,
new MythEvent("PERSISTENT_CONNECTION_FAILURE"));
Expand All @@ -875,13 +878,13 @@ bool MythCoreContext::SendReceiveStringList(QStringList &strlist,
else if (strlist[0] == "ERROR")
{
if (strlist.size() == 2)
VERBOSE(VB_GENERAL, QString("Protocol query '%1' reponded "
"with the error '%2'")
.arg(query_type).arg(strlist[1]));
LOG(VB_GENERAL, LOG_INFO,
QString("Protocol query '%1' responded with the error '%2'")
.arg(query_type).arg(strlist[1]));
else
VERBOSE(VB_GENERAL, QString("Protocol query '%1' reponded "
"with an error, but no error message.")
.arg(query_type));
LOG(VB_GENERAL, LOG_INFO,
QString("Protocol query '%1' responded with an error, but "
"no error message.") .arg(query_type));

ok = false;
}
Expand All @@ -907,15 +910,15 @@ void MythCoreContext::readyRead(MythSocket *sock)
}
else if (prefix != "BACKEND_MESSAGE")
{
VERBOSE(VB_IMPORTANT,
QString("Received a: %1 message from the backend"
"\n\t\t\tBut I don't know what to do with it.")
.arg(prefix));
LOG(VB_GENERAL, LOG_ERR,
QString("Received a: %1 message from the backend "
"but I don't know what to do with it.")
.arg(prefix));
}
else if (message == "CLEAR_SETTINGS_CACHE")
{
// No need to dispatch this message to ourself, so handle it
VERBOSE(VB_GENERAL, "Received a remote 'Clear Cache' request");
LOG(VB_GENERAL, LOG_INFO, "Received remote 'Clear Cache' request");
ClearSettingsCache();
}
else
Expand All @@ -932,8 +935,8 @@ void MythCoreContext::connectionClosed(MythSocket *sock)
{
(void)sock;

VERBOSE(VB_IMPORTANT, QString("Event socket closed. "
"No connection to the backend."));
LOG(VB_GENERAL, LOG_CRIT, "Event socket closed. No connection to the "
"backend.");

QMutexLocker locker(&d->m_sockLock);
if (d->m_serverSock)
Expand Down Expand Up @@ -963,7 +966,7 @@ bool MythCoreContext::CheckProtoVersion(MythSocket *socket, uint timeout_ms,

if (!socket->readStringList(strlist, timeout_ms) || strlist.empty())
{
VERBOSE(VB_IMPORTANT, "Protocol version check failure.\n\t\t\t"
LOG(VB_GENERAL, LOG_CRIT, "Protocol version check failure.\n\t\t\t"
"The response to MYTH_PROTO_VERSION was empty.\n\t\t\t"
"This happens when the backend is too busy to respond,\n\t\t\t"
"or has deadlocked in due to bugs or hardware failure.");
Expand All @@ -972,12 +975,11 @@ bool MythCoreContext::CheckProtoVersion(MythSocket *socket, uint timeout_ms,
}
else if (strlist[0] == "REJECT" && strlist.size() >= 2)
{
VERBOSE(VB_GENERAL, QString("Protocol version or token mismatch "
"(frontend=%1/%2,"
"backend=%3/\?\?)\n")
.arg(MYTH_PROTO_VERSION)
.arg(MYTH_PROTO_TOKEN)
.arg(strlist[1]));
LOG(VB_GENERAL, LOG_CRIT, QString("Protocol version or token mismatch "
"(frontend=%1/%2,backend=%3/\?\?)\n")
.arg(MYTH_PROTO_VERSION)
.arg(MYTH_PROTO_TOKEN)
.arg(strlist[1]));

if (error_dialog_desired && d->m_GUIcontext)
{
Expand All @@ -990,26 +992,27 @@ bool MythCoreContext::CheckProtoVersion(MythSocket *socket, uint timeout_ms,
}
else if (strlist[0] == "ACCEPT")
{
VERBOSE(VB_IMPORTANT, QString("Using protocol version %1")
.arg(MYTH_PROTO_VERSION));
LOG(VB_GENERAL, LOG_INFO, QString("Using protocol version %1")
.arg(MYTH_PROTO_VERSION));
return true;
}

VERBOSE(VB_GENERAL, QString("Unexpected response to MYTH_PROTO_VERSION: %1")
.arg(strlist[0]));
LOG(VB_GENERAL, LOG_ERR,
QString("Unexpected response to MYTH_PROTO_VERSION: %1")
.arg(strlist[0]));
return false;
}

void MythCoreContext::dispatch(const MythEvent &event)
{
VERBOSE(VB_NETWORK, QString("MythEvent: %1").arg(event.Message()));
LOG(VB_NETWORK, LOG_INFO, QString("MythEvent: %1").arg(event.Message()));

MythObservable::dispatch(event);
}

void MythCoreContext::dispatchNow(const MythEvent &event)
{
VERBOSE(VB_NETWORK, QString("MythEvent: %1").arg(event.Message()));
LOG(VB_NETWORK, LOG_INFO, QString("MythEvent: %1").arg(event.Message()));

MythObservable::dispatchNow(event);
}
Expand Down Expand Up @@ -1088,15 +1091,15 @@ void MythCoreContext::SaveLocaleDefaults(void)

if (!d->m_locale->GetLocaleCode().isEmpty())
{
VERBOSE(VB_GENERAL, QString("Current locale %1")
.arg(d->m_locale->GetLocaleCode()));
LOG(VB_GENERAL, LOG_INFO,
QString("Current locale %1") .arg(d->m_locale->GetLocaleCode()));

d->m_locale->SaveLocaleDefaults();
return;
}

VERBOSE(VB_IMPORTANT, QString("No locale defined! We weren't able to "
"set locale defaults."));
LOG(VB_GENERAL, LOG_ERR,
"No locale defined! We weren't able to set locale defaults.");
}

/* vim: set expandtab tabstop=4 shiftwidth=4: */
8 changes: 4 additions & 4 deletions mythtv/libs/libmythbase/mythcoreutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool extractZIP(const QString &zipFile, const QString &outDir)

if (ec != UnZip::Ok)
{
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_CRIT,
QString("extractZIP(): Unable to open ZIP file %1")
.arg(zipFile));
return false;
Expand All @@ -85,7 +85,7 @@ bool extractZIP(const QString &zipFile, const QString &outDir)

if (ec != UnZip::Ok)
{
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_CRIT,
QString("extractZIP(): Error extracting ZIP file %1")
.arg(zipFile));
return false;
Expand All @@ -109,8 +109,8 @@ static QString downloadRemoteFile(const QString &cmd, const QString &url,

if (!ok || strlist.size() < 2 || strlist[0] != "OK")
{
VERBOSE(VB_IMPORTANT, QString("downloadRemoteFile(): ") + cmd +
" returned ERROR!");
LOG(VB_GENERAL, LOG_CRIT, "downloadRemoteFile(): " + cmd +
" returned ERROR!");
return QString();
}

Expand Down
51 changes: 25 additions & 26 deletions mythtv/libs/libmythbase/mythdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ using namespace std;
static MythDB *mythdb = NULL;
static QMutex dbLock;

unsigned int db_messages = VB_IMPORTANT | VB_GENERAL;

// For thread safety reasons this is not a QString
const char *kSentinelValue = "<settings_sentinel_value>";

Expand Down Expand Up @@ -107,7 +105,7 @@ MythDBPrivate::MythDBPrivate()

MythDBPrivate::~MythDBPrivate()
{
VERBOSE(VB_DATABASE, "Destroying MythDBPrivate");
LOG(VB_DATABASE, LOG_INFO, "Destroying MythDBPrivate");
delete m_settings;
}

Expand Down Expand Up @@ -177,7 +175,7 @@ void MythDB::DBError(const QString &where, const QSqlQuery& query)
str += tmp;
}
str += DBErrorMessage(query.lastError());
VERBOSE(VB_IMPORTANT, QString("%1").arg(str));
LOG(VB_GENERAL, LOG_ERR, str);
}

QString MythDB::DBErrorMessage(const QSqlError& err)
Expand Down Expand Up @@ -257,7 +255,7 @@ bool MythDB::SaveSettingOnHost(const QString &key,
QString LOC = QString("SaveSettingOnHost('%1') ").arg(key);
if (key.isEmpty())
{
VERBOSE(VB_IMPORTANT, LOC + "- Illegal null key");
LOG(VB_GENERAL, LOG_ERR, "Illegal null key");
return false;
}

Expand All @@ -273,7 +271,7 @@ bool MythDB::SaveSettingOnHost(const QString &key,
if (host.toLower() == d->m_localhostname)
OverrideSettingForSession(key, newValue);
if (!d->suppressDBMessages)
VERBOSE(VB_IMPORTANT, LOC + "- No database yet");
LOG(VB_GENERAL, LOG_ERR, "No database yet");
SingleSetting setting;
setting.host = host;
setting.key = key;
Expand Down Expand Up @@ -321,7 +319,7 @@ bool MythDB::SaveSettingOnHost(const QString &key,
}
else
{
VERBOSE(VB_IMPORTANT, LOC + "- database not open");
LOG(VB_GENERAL, LOG_ERR, "database not open");
}

ClearSettingsCache(host + ' ' + key);
Expand Down Expand Up @@ -364,7 +362,7 @@ QString MythDB::GetSetting(const QString &_key, const QString &defaultval)
if (!query.isConnected())
{
if (!d->suppressDBMessages)
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_ERR,
QString("Database not open while trying to load setting: %1")
.arg(key));
return d->m_settings->GetSetting(key, defaultval);
Expand Down Expand Up @@ -613,7 +611,7 @@ QString MythDB::GetSettingOnHost(const QString &_key, const QString &_host,
if (!query.isConnected())
{
if (!d->suppressDBMessages)
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_ERR,
QString("Database not open while trying to "
"load setting: %1").arg(key));
return value;
Expand Down Expand Up @@ -768,8 +766,8 @@ void MythDB::OverrideSettingForSession(
QString mk = key.toLower(), mk2 = d->m_localhostname + ' ' + mk, mv = value;
if ("dbschemaver" == mk)
{
VERBOSE(VB_IMPORTANT, QString("ERROR: Refusing to allow override "
"for '%1'.").arg(key));
LOG(VB_GENERAL, LOG_ERR,
QString("ERROR: Refusing to allow override for '%1'.").arg(key));
return;
}
mk.squeeze();
Expand All @@ -793,13 +791,13 @@ static void clear(
SettingsMap::const_iterator oit = overrides.find(myKey);
if (oit == overrides.end())
{
VERBOSE(VB_DATABASE,
LOG(VB_DATABASE, LOG_INFO,
QString("Clearing Settings Cache for '%1'.").arg(myKey));
cache.erase(it);
}
else
{
VERBOSE(VB_DATABASE,
LOG(VB_DATABASE, LOG_INFO,
QString("Clearing Cache of overridden '%1' ignored.")
.arg(myKey));
}
Expand All @@ -812,7 +810,7 @@ void MythDB::ClearSettingsCache(const QString &_key)

if (_key.isEmpty())
{
VERBOSE(VB_DATABASE, "Clearing Settings Cache.");
LOG(VB_DATABASE, LOG_INFO, "Clearing Settings Cache.");
d->settingsCache.clear();
d->settingsCache.reserve(settings_reserve);

Expand Down Expand Up @@ -843,9 +841,9 @@ void MythDB::ClearSettingsCache(const QString &_key)
void MythDB::ActivateSettingsCache(bool activate)
{
if (activate)
VERBOSE(VB_DATABASE, "Enabling Settings Cache.");
LOG(VB_DATABASE, LOG_INFO, "Enabling Settings Cache.");
else
VERBOSE(VB_DATABASE, "Disabling Settings Cache.");
LOG(VB_DATABASE, LOG_INFO, "Disabling Settings Cache.");

d->useSettingsCache = activate;
ClearSettingsCache();
Expand Down Expand Up @@ -878,7 +876,7 @@ bool MythDB::LoadDatabaseParamsFromDisk(
}
else if (sanitize)
{
VERBOSE(VB_IMPORTANT, "Unable to read configuration file mysql.txt");
LOG(VB_GENERAL, LOG_ERR, "Unable to read configuration file mysql.txt");

// Sensible connection defaults.
params.dbHostName = "localhost";
Expand All @@ -904,15 +902,15 @@ bool MythDB::LoadDatabaseParamsFromDisk(

if (params.dbHostName.isEmpty())
{
VERBOSE(VB_IMPORTANT, "DBHostName is not set in mysql.txt");
VERBOSE(VB_IMPORTANT, "Assuming localhost");
LOG(VB_GENERAL, LOG_ERR, "DBHostName is not set in mysql.txt");
LOG(VB_GENERAL, LOG_ERR, "Assuming localhost");
}
if (params.dbUserName.isEmpty())
VERBOSE(VB_IMPORTANT, "DBUserName is not set in mysql.txt");
LOG(VB_GENERAL, LOG_ERR, "DBUserName is not set in mysql.txt");
if (params.dbPassword.isEmpty())
VERBOSE(VB_IMPORTANT, "DBPassword is not set in mysql.txt");
LOG(VB_GENERAL, LOG_ERR, "DBPassword is not set in mysql.txt");
if (params.dbName.isEmpty())
VERBOSE(VB_IMPORTANT, "DBName is not set in mysql.txt");
LOG(VB_GENERAL, LOG_ERR, "DBName is not set in mysql.txt");

// If sanitize set, replace empty dbHostName with "localhost"
if (sanitize && params.dbHostName.isEmpty())
Expand All @@ -939,19 +937,20 @@ bool MythDB::SaveDatabaseParamsToDisk(
{
if (!createDir.mkdir(dirpath))
{
VERBOSE(VB_IMPORTANT, QString("Could not create %1").arg(dirpath));
LOG(VB_GENERAL, LOG_ERR,
QString("Could not create %1").arg(dirpath));
return false;
}
}

if (!f->open(QIODevice::WriteOnly))
{
VERBOSE(VB_IMPORTANT, QString("Could not open settings file %1 "
"for writing").arg(path));
LOG(VB_GENERAL, LOG_ERR, QString("Could not open settings file %1 "
"for writing").arg(path));
return false;
}

VERBOSE(VB_IMPORTANT, QString("Writing settings file %1").arg(path));
LOG(VB_GENERAL, LOG_NOTICE, QString("Writing settings file %1").arg(path));
QTextStream s(f);
s << "DBHostName=" << params.dbHostName << endl;

Expand Down
81 changes: 42 additions & 39 deletions mythtv/libs/libmythbase/mythdbcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ MSqlDatabase::MSqlDatabase(const QString &name)
m_name = name;
m_name.detach();
m_db = QSqlDatabase::addDatabase("QMYSQL", m_name);
VERBOSE(VB_IMPORTANT, "Database connection created: " + m_name);
LOG(VB_GENERAL, LOG_INFO, "Database connection created: " + m_name);

if (!m_db.isValid())
{
VERBOSE(VB_IMPORTANT,
"Unable to init db connection.");
LOG(VB_GENERAL, LOG_ERR, "Unable to init db connection.");
return;
}
m_lastDBKick = QDateTime::currentDateTime().addSecs(-60);
Expand All @@ -84,7 +83,7 @@ MSqlDatabase::~MSqlDatabase()
// removeDatabase() so that connections
// and queries are cleaned up correctly
QSqlDatabase::removeDatabase(m_name);
VERBOSE(VB_IMPORTANT, "Database connection deleted: " + m_name);
LOG(VB_GENERAL, LOG_INFO, "Database connection deleted: " + m_name);
}
}

Expand All @@ -102,7 +101,7 @@ bool MSqlDatabase::OpenDatabase(bool skipdb)
{
if (!m_db.isValid())
{
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_ERR,
"MSqlDatabase::OpenDatabase(), db object is not valid!");
return false;
}
Expand Down Expand Up @@ -143,13 +142,14 @@ bool MSqlDatabase::OpenDatabase(bool skipdb)

while (!connected && trycount++ < m_dbparms.wolRetry)
{
VERBOSE(VB_GENERAL, QString(
"Using WOL to wakeup database server (Try %1 of %2)")
LOG(VB_GENERAL, LOG_INFO,
QString("Using WOL to wakeup database server (Try %1 of "
"%2)")
.arg(trycount).arg(m_dbparms.wolRetry));

if (myth_system(m_dbparms.wolCommand) != GENERIC_EXIT_OK)
{
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_ERR,
QString("Failed to run WOL command '%1'")
.arg(m_dbparms.wolCommand));
}
Expand All @@ -160,12 +160,13 @@ bool MSqlDatabase::OpenDatabase(bool skipdb)

if (!connected)
{
VERBOSE(VB_IMPORTANT, "WOL failed, unable to connect to database!");
LOG(VB_GENERAL, LOG_ERR,
"WOL failed, unable to connect to database!");
}
}
if (connected)
{
VERBOSE(VB_GENERAL,
LOG(VB_GENERAL, LOG_INFO,
QString("Connected to database '%1' at host: %2")
.arg(m_db.databaseName()).arg(m_db.hostName()));

Expand Down Expand Up @@ -201,8 +202,8 @@ bool MSqlDatabase::OpenDatabase(bool skipdb)
if (!connected)
{
GetMythDB()->SetHaveDBConnection(false);
VERBOSE(VB_IMPORTANT, "Unable to connect to database!");
VERBOSE(VB_IMPORTANT, MythDB::DBErrorMessage(m_db.lastError()));
LOG(VB_GENERAL, LOG_ERR, "Unable to connect to database!");
LOG(VB_GENERAL, LOG_ERR, MythDB::DBErrorMessage(m_db.lastError()));
}

return connected;
Expand Down Expand Up @@ -247,7 +248,7 @@ bool MSqlDatabase::KickDatabase()
m_db.open();
}
else
VERBOSE(VB_IMPORTANT, MythDB::DBErrorMessage(m_db.lastError()));
LOG(VB_GENERAL, LOG_ERR, MythDB::DBErrorMessage(m_db.lastError()));
}

m_lastDBKick = QDateTime::currentDateTime().addSecs(-60);
Expand All @@ -262,7 +263,7 @@ bool MSqlDatabase::Reconnect()

bool open = m_db.isOpen();
if (open)
VERBOSE(VB_IMPORTANT, "MySQL reconnected successfully");
LOG(VB_GENERAL, LOG_INFO, "MySQL reconnected successfully");

return open;
}
Expand Down Expand Up @@ -307,7 +308,7 @@ MSqlDatabase *MDBManager::popConnection()
{
db = new MSqlDatabase("DBManager" + QString::number(m_nextConnID++));
++m_connCount;
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_INFO,
QString("New DB connection, total: %1").arg(m_connCount));
}
else
Expand Down Expand Up @@ -378,21 +379,21 @@ void MDBManager::PurgeIdleConnections(void)
newDb = new MSqlDatabase("DBManager" +
QString::number(m_nextConnID++));
++m_connCount;
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_INFO,
QString("New DB connection, total: %1").arg(m_connCount));
newDb->m_lastDBKick = QDateTime::currentDateTime();
}

VERBOSE(VB_DATABASE, "Deleting idle DB connection...");
LOG(VB_DATABASE, LOG_INFO, "Deleting idle DB connection...");
delete entry;
VERBOSE(VB_DATABASE, "Done deleting idle DB connection.");
LOG(VB_DATABASE, LOG_INFO, "Done deleting idle DB connection.");
}
if (newDb)
m_pool.push_front(newDb);

if (purgedConnections)
{
VERBOSE(VB_DATABASE,
LOG(VB_DATABASE, LOG_INFO,
QString("Purged %1 idle of %2 total DB connections.")
.arg(purgedConnections).arg(totalConnections));
}
Expand All @@ -406,7 +407,7 @@ MSqlDatabase *MDBManager::getStaticCon(MSqlDatabase **dbcon, QString name)
if (!*dbcon)
{
*dbcon = new MSqlDatabase(name);
VERBOSE(VB_IMPORTANT, "New static DB connection" + name);
LOG(VB_GENERAL, LOG_INFO, "New static DB connection" + name);
}

(*dbcon)->OpenDatabase();
Expand Down Expand Up @@ -465,8 +466,8 @@ void MDBManager::CloseDatabases()
while (it != m_pool.end())
{
db = *it;
VERBOSE(VB_IMPORTANT,
"Closing DB connection named '" + db->m_name + '\'');
LOG(VB_GENERAL, LOG_INFO,
"Closing DB connection named '" + db->m_name + "'");
db->m_db.close();
++it;
}
Expand Down Expand Up @@ -629,7 +630,7 @@ bool MSqlQuery::exec()

if (!m_db->isOpen() && !m_db->Reconnect())
{
VERBOSE(VB_IMPORTANT, "MySQL server disconnected");
LOG(VB_GENERAL, LOG_INFO, "MySQL server disconnected");
return false;
}

Expand All @@ -656,12 +657,11 @@ bool MSqlQuery::exec()
str.replace(b.key(), '\'' + b.value().toString() + '\'');
}

VERBOSE(VB_DATABASE,
LOG(VB_DATABASE, LOG_DEBUG,
QString("MSqlQuery::exec(%1) %2%3")
.arg(m_db->MSqlDatabase::GetConnectionName()).arg(str)
.arg(isSelect() ? QString(" <<<< Returns %1 row(s)")
.arg(size())
: QString()));
.arg(isSelect() ? QString(" <<<< Returns %1 row(s)")
.arg(size()) : QString()));
}

return result;
Expand All @@ -673,7 +673,7 @@ bool MSqlQuery::exec(const QString &query)
// down
if (!m_db->isOpen() && !m_db->Reconnect())
{
VERBOSE(VB_IMPORTANT, "MySQL server disconnected");
LOG(VB_GENERAL, LOG_INFO, "MySQL server disconnected");
return false;
}

Expand All @@ -685,12 +685,11 @@ bool MSqlQuery::exec(const QString &query)
if (!result && QSqlQuery::lastError().number() == 2006 && m_db->Reconnect())
result = QSqlQuery::exec(query);

VERBOSE(VB_DATABASE,
LOG(VB_DATABASE, LOG_DEBUG,
QString("MSqlQuery::exec(%1) %2%3")
.arg(m_db->MSqlDatabase::GetConnectionName()).arg(query)
.arg(isSelect() ? QString(" <<<< Returns %1 row(s)")
.arg(size())
: QString()));
.arg(size()) : QString()));

return result;
}
Expand All @@ -712,7 +711,7 @@ bool MSqlQuery::next()
str.append(record.fieldName(i) + " = " + value(i).toString());
}

VERBOSE(VB_DATABASE+VB_EXTRA,
LOG(VB_DATABASE, LOG_DEBUG,
QString("MSqlQuery::next(%1) Result: \"%2\"")
.arg(m_db->MSqlDatabase::GetConnectionName())
.arg(str));
Expand All @@ -727,10 +726,12 @@ bool MSqlQuery::prepare(const QString& query)
#ifdef DEBUG_QT4_PORT
if (query.contains(m_testbindings))
{
VERBOSE(VB_IMPORTANT,
LOG(VB_GENERAL, LOG_DEBUG,
QString("\n\nQuery contains bind value \"%1\" twice:\n\n\n")
.arg(m_testbindings.cap(1)) + query);
//exit(1);
#if 0
exit(1);
#endif
}
#endif

Expand All @@ -744,7 +745,7 @@ bool MSqlQuery::prepare(const QString& query)

if (!m_db->isOpen() && !m_db->Reconnect())
{
VERBOSE(VB_IMPORTANT, "MySQL server disconnected");
LOG(VB_GENERAL, LOG_INFO, "MySQL server disconnected");
return false;
}

Expand All @@ -758,8 +759,10 @@ bool MSqlQuery::prepare(const QString& query)

if (!ok && !(GetMythDB()->SuppressDBMessages()))
{
VERBOSE(VB_IMPORTANT, QString("Error preparing query: %1").arg(query));
VERBOSE(VB_IMPORTANT, MythDB::DBErrorMessage(QSqlQuery::lastError()));
LOG(VB_GENERAL, LOG_ERR,
QString("Error preparing query: %1").arg(query));
LOG(VB_GENERAL, LOG_ERR,
MythDB::DBErrorMessage(QSqlQuery::lastError()));
}

return ok;
Expand All @@ -785,8 +788,8 @@ void MSqlQuery::bindValue (const QString & placeholder,
// qt4 doesn't like to bind values without occurrence in the prepared query
if (!m_last_prepared_query.contains(placeholder))
{
VERBOSE(VB_IMPORTANT, "Trying to bind a value to placeholder "
+ placeholder + " without occurrence in the prepared query."
LOG(VB_GENERAL, LOG_ERR, "Trying to bind a value to placeholder " +
placeholder + " without occurrence in the prepared query."
" Ignoring it.\nQuery was: \"" + m_last_prepared_query + "\"");
return;
}
Expand Down
13 changes: 7 additions & 6 deletions mythtv/libs/libmythbase/mythdirs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,27 @@ void InitializeMythDirs(void)
// executable directory. This can be fragile on Unix, so
// use relative PREFIX values with care.

VERBOSE(VB_IMPORTANT+VB_EXTRA,
"Relative PREFIX! (" + installprefix +
")\n\t\tappDir=" + prefixDir.canonicalPath());
LOG(VB_GENERAL, LOG_DEBUG,
"Relative PREFIX! (" + installprefix + ")\n\t\tappDir=" +
prefixDir.canonicalPath());

prefixDir.cd(installprefix);
installprefix = prefixDir.canonicalPath();
}

VERBOSE(VB_IMPORTANT, "Using runtime prefix = " + installprefix);
LOG(VB_GENERAL, LOG_CRIT, "Using runtime prefix = " + installprefix);

char *tmp_confdir = std::getenv("MYTHCONFDIR");
if (tmp_confdir)
{
confdir = QString(tmp_confdir);
VERBOSE(VB_IMPORTANT, QString("Read conf dir = %1").arg(confdir));
LOG(VB_GENERAL, LOG_CRIT, QString("Read conf dir = %1").arg(confdir));
confdir.replace("$HOME", QDir::homePath());
}
else
confdir = QDir::homePath() + "/.mythtv";

VERBOSE(VB_IMPORTANT, QString("Using configuration directory = %1")
LOG(VB_GENERAL, LOG_CRIT, QString("Using configuration directory = %1")
.arg(confdir));

sharedir = installprefix + "/share/mythtv/";
Expand Down
50 changes: 24 additions & 26 deletions mythtv/libs/libmythbase/mythdownloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ bool MythDownloadManager::processItem(const QString &url, QNetworkRequest *req,
*/
void MythDownloadManager::preCache(const QString &url)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("preCache('%1')").arg(url));
LOG(VB_FILE, LOG_DEBUG, QString("preCache('%1')").arg(url));
queueItem(url, NULL, QString(), NULL, NULL);
}

Expand All @@ -358,7 +358,7 @@ void MythDownloadManager::queueDownload(const QString &url,
QObject *caller,
const bool reload)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("queueDownload('%1', '%2', %3)")
LOG(VB_FILE, LOG_DEBUG, QString("queueDownload('%1', '%2', %3)")
.arg(url).arg(dest).arg((long long)caller));

queueItem(url, NULL, dest, NULL, caller, false, reload);
Expand All @@ -376,7 +376,7 @@ void MythDownloadManager::queueDownload(QNetworkRequest *req,
QByteArray *data,
QObject *caller)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("queueDownload('%1', '%2', %3)")
LOG(VB_FILE, LOG_DEBUG, QString("queueDownload('%1', '%2', %3)")
.arg(req->url().toString()).arg((long long)data).arg((long long)caller));

queueItem(req->url().toString(), req, QString(), data, caller);
Expand Down Expand Up @@ -452,7 +452,7 @@ QNetworkReply *MythDownloadManager::download(const QString &url,
*/
bool MythDownloadManager::download(QNetworkRequest *req, QByteArray *data)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("download('%1', '%2')")
LOG(VB_FILE, LOG_DEBUG, QString("download('%1', '%2')")
.arg(req->url().toString()).arg((long long)data));
return processItem(req->url().toString(), req, QString(), data);
}
Expand All @@ -469,12 +469,12 @@ void MythDownloadManager::queuePost(const QString &url,
QByteArray *data,
QObject *caller)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("queuePost('%1', '%2')")
LOG(VB_FILE, LOG_DEBUG, QString("queuePost('%1', '%2')")
.arg(url).arg((long long)data));

if (!data)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "queuePost(), data is NULL!");
LOG(VB_GENERAL, LOG_ERR, "queuePost(), data is NULL!");
return;
}

Expand All @@ -493,12 +493,12 @@ void MythDownloadManager::queuePost(QNetworkRequest *req,
QByteArray *data,
QObject *caller)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("queuePost('%1', '%2')")
LOG(VB_FILE, LOG_DEBUG, QString("queuePost('%1', '%2')")
.arg(req->url().toString()).arg((long long)data));

if (!data)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "queuePost(), data is NULL!");
LOG(VB_GENERAL, LOG_ERR, "queuePost(), data is NULL!");
return;
}

Expand All @@ -513,12 +513,12 @@ void MythDownloadManager::queuePost(QNetworkRequest *req,
*/
bool MythDownloadManager::post(const QString &url, QByteArray *data)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("post('%1', '%2')")
LOG(VB_FILE, LOG_DEBUG, QString("post('%1', '%2')")
.arg(url).arg((long long)data));

if (!data)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "post(), data is NULL!");
LOG(VB_GENERAL, LOG_ERR, "post(), data is NULL!");
return false;
}

Expand All @@ -533,12 +533,12 @@ bool MythDownloadManager::post(const QString &url, QByteArray *data)
*/
bool MythDownloadManager::post(QNetworkRequest *req, QByteArray *data)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("post('%1', '%2')")
LOG(VB_FILE, LOG_DEBUG, QString("post('%1', '%2')")
.arg(req->url().toString()).arg((long long)data));

if (!data)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "post(), data is NULL!");
LOG(VB_GENERAL, LOG_ERR, "post(), data is NULL!");
return false;
}

Expand Down Expand Up @@ -714,8 +714,7 @@ void MythDownloadManager::downloadError(QNetworkReply::NetworkError errorCode)
{
QNetworkReply *reply = (QNetworkReply*)sender();

VERBOSE(VB_FILE+VB_EXTRA, LOC +
QString("downloadError(%1) (for reply %2)")
LOG(VB_FILE, LOG_DEBUG, QString("downloadError(%1) (for reply %2)")
.arg(errorCode).arg((long long)reply));

QMutexLocker locker(m_infoLock);
Expand Down Expand Up @@ -743,7 +742,7 @@ void MythDownloadManager::downloadError(QNetworkReply::NetworkError errorCode)
QUrl MythDownloadManager::redirectUrl(const QUrl& possibleRedirectUrl,
const QUrl& oldRedirectUrl) const
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("redirectUrl()"));
LOG(VB_FILE, LOG_DEBUG, QString("redirectUrl()"));
QUrl redirectUrl;

if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
Expand All @@ -758,7 +757,7 @@ QUrl MythDownloadManager::redirectUrl(const QUrl& possibleRedirectUrl,
*/
void MythDownloadManager::downloadFinished(QNetworkReply* reply)
{
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("downloadFinished(%1)")
LOG(VB_FILE, LOG_DEBUG, QString("downloadFinished(%1)")
.arg((long long)reply));

QMutexLocker locker(m_infoLock);
Expand Down Expand Up @@ -795,7 +794,7 @@ void MythDownloadManager::downloadFinished(MythDownloadInfo *dlInfo)

if(!dlInfo->m_redirectedTo.isEmpty())
{
VERBOSE(VB_FILE+VB_EXTRA, LOC +
LOG(VB_FILE, LOG_DEBUG,
QString("downloadFinished(%1): Redirect: %2 -> %3")
.arg((long long)dlInfo)
.arg(reply->url().toString())
Expand Down Expand Up @@ -825,7 +824,7 @@ void MythDownloadManager::downloadFinished(MythDownloadInfo *dlInfo)
}
else
{
VERBOSE(VB_FILE+VB_EXTRA, QString("downloadFinished(%1): COMPLETE: %2")
LOG(VB_FILE, LOG_DEBUG, QString("downloadFinished(%1): COMPLETE: %2")
.arg((long long)dlInfo).arg(dlInfo->m_url));

dlInfo->m_redirectedTo.clear();
Expand Down Expand Up @@ -885,7 +884,7 @@ void MythDownloadManager::downloadFinished(MythDownloadInfo *dlInfo)
{
if (dlInfo->m_caller)
{
VERBOSE(VB_FILE+VB_EXTRA, QString("downloadFinished(%1): "
LOG(VB_FILE, LOG_DEBUG, QString("downloadFinished(%1): "
"COMPLETE: %2, sending event to caller")
.arg((long long)dlInfo).arg(dlInfo->m_url));

Expand Down Expand Up @@ -917,7 +916,7 @@ void MythDownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTot
{
QNetworkReply *reply = (QNetworkReply*)sender();

VERBOSE(VB_FILE+VB_EXTRA, LOC +
LOG(VB_FILE, LOG_DEBUG,
QString("downloadProgress(%1, %2) (for reply %3)")
.arg(bytesReceived).arg(bytesTotal).arg((long long)reply));

Expand All @@ -932,14 +931,14 @@ void MythDownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTot

dlInfo->m_lastStat = QDateTime::currentDateTime();

VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("downloadProgress: %1 "
LOG(VB_FILE, LOG_DEBUG, QString("downloadProgress: %1 "
"to %2 is at %3 of %4 bytes downloaded")
.arg(dlInfo->m_url).arg(dlInfo->m_outFile)
.arg(bytesReceived).arg(bytesTotal));

if (!dlInfo->m_syncMode && dlInfo->m_caller)
{
VERBOSE(VB_FILE+VB_EXTRA, QString("downloadProgress(%1): "
LOG(VB_FILE, LOG_DEBUG, QString("downloadProgress(%1): "
"sending event to caller")
.arg(reply->url().toString()));

Expand Down Expand Up @@ -988,7 +987,7 @@ bool MythDownloadManager::saveFile(const QString &outFile,

if (!qdir.exists() && !qdir.mkpath(fileInfo.absolutePath()))
{
VERBOSE(VB_IMPORTANT, QString("Failed to create: '%1'")
LOG(VB_GENERAL, LOG_ERR, QString("Failed to create: '%1'")
.arg(fileInfo.absolutePath()));
return false;
}
Expand All @@ -999,8 +998,7 @@ bool MythDownloadManager::saveFile(const QString &outFile,

if (!file.open(mode))
{
VERBOSE(VB_IMPORTANT, QString("Failed to open: '%1'")
.arg(outFile));
LOG(VB_GENERAL, LOG_ERR, QString("Failed to open: '%1'") .arg(outFile));
return false;
}

Expand Down Expand Up @@ -1036,7 +1034,7 @@ bool MythDownloadManager::saveFile(const QString &outFile,
QDateTime MythDownloadManager::GetLastModified(const QString &url)
{
static const char dateFormat[] = "ddd, dd MMM yyyy hh:mm:ss 'GMT'";
VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("GetLastModified('%1')").arg(url));
LOG(VB_FILE, LOG_DEBUG, QString("GetLastModified('%1')").arg(url));
QDateTime result;

QDateTime now = QDateTime::currentDateTime();
Expand Down
15 changes: 7 additions & 8 deletions mythtv/libs/libmythbase/mythhttphandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void MythHttpHandler::AddUrlRequest(const QUrl &url)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC +
LOG(VB_NETWORK, LOG_DEBUG,
QString("AddUrlRequest(%1)").arg(url.toString()));

if (!m_qhttp->hasPendingRequests() && !m_qhttp->currentRequest().isValid())
Expand All @@ -68,8 +68,7 @@ void MythHttpHandler::AddUrlRequest(const QUrl &url)

void MythHttpHandler::Get(const QUrl &url)
{
VERBOSE(VB_NETWORK, LOC +
QString("Get(%1)").arg(url.toString()));
LOG(VB_NETWORK, LOG_DEBUG, QString("Get(%1)").arg(url.toString()));

m_cur_url = url;
m_cur_status_id = 0;
Expand Down Expand Up @@ -124,7 +123,7 @@ void MythHttpHandler::Done(bool error)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("Done(%1) url: %2")
LOG(VB_NETWORK, LOG_DEBUG, QString("Done(%1) url: %2")
.arg(error).arg(m_cur_url.toString()));

if (m_pool)
Expand All @@ -135,7 +134,7 @@ void MythHttpHandler::ResponseHeaderReceived(const QHttpResponseHeader &resp)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("ResponseHeaderReceived(%1,%2) url: %3")
LOG(VB_NETWORK, LOG_DEBUG, QString("ResponseHeaderReceived(%1,%2) url: %3")
.arg(resp.statusCode()).arg(resp.reasonPhrase())
.arg(m_cur_url.toString()));
m_cur_status_id = resp.statusCode();
Expand Down Expand Up @@ -190,7 +189,7 @@ void MythHttpHandler::RequestFinished(int id, bool error)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("RequestFinished(%1,%2) url: %3")
LOG(VB_NETWORK, LOG_DEBUG, QString("RequestFinished(%1,%2) url: %3")
.arg(id).arg(error).arg(m_cur_url.toString()));
if (error && m_pool)
{
Expand Down Expand Up @@ -237,15 +236,15 @@ void MythHttpHandler::RequestStarted(int id)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("RequestStarted(%1) url: %2")
LOG(VB_NETWORK, LOG_DEBUG, QString("RequestStarted(%1) url: %2")
.arg(id).arg(m_cur_url.toString()));
}

void MythHttpHandler::StateChanged(int state)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("StateChanged(%1) url: %2")
LOG(VB_NETWORK, LOG_DEBUG, QString("StateChanged(%1) url: %2")
.arg(state).arg(m_cur_url.toString()));
}

10 changes: 5 additions & 5 deletions mythtv/libs/libmythbase/mythhttppool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void MythHttpPool::AddUrlRequest(const QUrl &url, MythHttpListener *listener)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("AddUrlRequest(%1, 0x%2)")
LOG(VB_NETWORK, LOG_DEBUG, QString("AddUrlRequest(%1, 0x%2)")
.arg(url.toString()).arg((quint64)listener,0,16));

bool in_queue = m_urlToListener.find(url) != m_urlToListener.end();
Expand Down Expand Up @@ -84,15 +84,15 @@ void MythHttpPool::RemoveUrlRequest(const QUrl &url, MythHttpListener *listener)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("RemoveUrlRequest(%1, 0x%2)")
LOG(VB_NETWORK, LOG_DEBUG, QString("RemoveUrlRequest(%1, 0x%2)")
.arg(url.toString()).arg((quint64)listener,0,16));
}

void MythHttpPool::RemoveListener(MythHttpListener *listener)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("RemoveListener(0x%1)")
LOG(VB_NETWORK, LOG_DEBUG, QString("RemoveListener(0x%1)")
.arg((quint64)listener,0,16));
set<MythHttpListener*>::iterator it = m_listeners.find(listener);
if (it != m_listeners.end())
Expand Down Expand Up @@ -126,13 +126,13 @@ void MythHttpPool::Done(const QString &host, MythHttpHandler *handler)
{
QMutexLocker locker(&m_lock);

VERBOSE(VB_NETWORK, LOC + QString("Done(%1, 0x%2)")
LOG(VB_NETWORK, LOG_DEBUG, QString("Done(%1, 0x%2)")
.arg(host).arg((quint64)handler,0,16));

HostToHandler::iterator it = m_hostToHandler.find(host);
if (handler != *it)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Done(%1, 0x%2)")
LOG(VB_GENERAL, LOG_ERR, QString("Done(%1, 0x%2)")
.arg(host).arg((quint64)handler,0,16));
return;
}
Expand Down
16 changes: 9 additions & 7 deletions mythtv/libs/libmythbase/mythlocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,26 @@ bool MythLocale::LoadDefaultsFromXML(void)

if (!file.exists())
{
VERBOSE(VB_GENERAL, QString("No locale defaults file for %1, "
"skipping").arg(m_localeCode));
LOG(VB_GENERAL, LOG_ERR,
QString("No locale defaults file for %1, skipping")
.arg(m_localeCode));
return false;
}
}

if (!file.open(QIODevice::ReadOnly))
{
VERBOSE(VB_IMPORTANT, QString("Unable to open %1")
LOG(VB_GENERAL, LOG_ERR, QString("Unable to open %1")
.arg(file.fileName()));
return false;
}

VERBOSE(VB_GENERAL, QString("Reading locale defaults from %1")
LOG(VB_GENERAL, LOG_ERR, QString("Reading locale defaults from %1")
.arg(file.fileName()));

if (!doc.setContent(&file))
{
VERBOSE(VB_IMPORTANT, QString("Unable to parse %1")
LOG(VB_GENERAL, LOG_ERR, QString("Unable to parse %1")
.arg(file.fileName()));

file.close();
Expand Down Expand Up @@ -147,8 +148,9 @@ bool MythLocale::LoadDefaultsFromXML(void)

if (m_globalSettings.isEmpty() && m_hostSettings.isEmpty())
{
VERBOSE(VB_GENERAL, QString("No locale defaults specified in %1, "
"skipping").arg(file.fileName()));
LOG(VB_GENERAL, LOG_ERR,
QString("No locale defaults specified in %1, skipping")
.arg(file.fileName()));
return false;
}

Expand Down
32 changes: 16 additions & 16 deletions mythtv/libs/libmythbase/mythlogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ FileLogger::FileLogger(char *filename) : LoggerBase(filename, 0),
{
m_opened = true;
m_fd = 1;
LOG(VB_IMPORTANT, LOG_INFO, "Added logging to the console");
LOG(VB_GENERAL, LOG_INFO, "Added logging to the console");
}
else
{
m_fd = open(filename, O_WRONLY|O_CREAT|O_APPEND, 0664);
m_opened = (m_fd != -1);
LOG(VB_IMPORTANT, LOG_INFO, QString("Added logging to %1")
LOG(VB_GENERAL, LOG_INFO, QString("Added logging to %1")
.arg(filename));
}
}
Expand All @@ -178,12 +178,12 @@ FileLogger::~FileLogger()
{
if( m_fd != 1 )
{
LOG(VB_IMPORTANT, LOG_INFO, QString("Removed logging to %1")
LOG(VB_GENERAL, LOG_INFO, QString("Removed logging to %1")
.arg(m_handle.string));
close( m_fd );
}
else
LOG(VB_IMPORTANT, LOG_INFO, "Removed logging to the console");
LOG(VB_GENERAL, LOG_INFO, "Removed logging to the console");
}
}

Expand All @@ -199,7 +199,7 @@ void FileLogger::reopen(void)

m_fd = open(filename, O_WRONLY|O_CREAT|O_APPEND, 0664);
m_opened = (m_fd != -1);
LOG(VB_IMPORTANT, LOG_INFO, QString("Rolled logging on %1")
LOG(VB_GENERAL, LOG_INFO, QString("Rolled logging on %1")
.arg(filename));
}

Expand Down Expand Up @@ -256,7 +256,7 @@ bool FileLogger::logmsg(LoggingItem_t *item)

if( result == -1 )
{
LOG(VB_IMPORTANT, LOG_UNKNOWN,
LOG(VB_GENERAL, LOG_ERR,
QString("Closed Log output on fd %1 due to errors").arg(m_fd));
m_opened = false;
if( m_fd != 1 )
Expand All @@ -282,13 +282,13 @@ SyslogLogger::SyslogLogger(int facility) : LoggerBase(NULL, facility),
for( name = &facilitynames[0];
name->c_name && name->c_val != facility; name++ );

LOG(VB_IMPORTANT, LOG_INFO, QString("Added syslogging to facility %1")
LOG(VB_GENERAL, LOG_INFO, QString("Added syslogging to facility %1")
.arg(name->c_name));
}

SyslogLogger::~SyslogLogger()
{
LOG(VB_IMPORTANT, LOG_INFO, "Removing syslogging");
LOG(VB_GENERAL, LOG_INFO, "Removing syslogging");
free(m_application);
closelog();
}
Expand Down Expand Up @@ -319,7 +319,7 @@ DatabaseLogger::DatabaseLogger(char *table) : LoggerBase(table, 0),
"msgtime, level, message) VALUES (:HOST, :APPLICATION, "
":PID, :THREAD, :MSGTIME, :LEVEL, :MESSAGE)";

LOG(VB_IMPORTANT, LOG_INFO,
LOG(VB_GENERAL, LOG_INFO,
QString("Added database logging to table %1")
.arg(m_handle.string));

Expand All @@ -342,7 +342,7 @@ DatabaseLogger::DatabaseLogger(char *table) : LoggerBase(table, 0),

DatabaseLogger::~DatabaseLogger()
{
LOG(VB_IMPORTANT, LOG_INFO, "Removing database logging");
LOG(VB_GENERAL, LOG_INFO, "Removing database logging");

if( m_thread )
{
Expand Down Expand Up @@ -552,8 +552,8 @@ LoggerThread::LoggerThread()
char *debug = getenv("VERBOSE_THREADS");
if (debug != NULL)
{
VERBOSE(VB_IMPORTANT, "Logging thread registration/deregistration "
"enabled!");
LOG(VB_GENERAL, LOG_CRIT, "Logging thread registration/deregistration "
"enabled!");
debugRegistration = true;
}
}
Expand Down Expand Up @@ -769,7 +769,7 @@ void LogPrintLine( uint32_t mask, LogLevel_t level, const char *file, int line,
#ifndef _WIN32
void logSighup( int signum, siginfo_t *info, void *secret )
{
VERBOSE(VB_GENERAL, "SIGHUP received, rolling log files.");
LOG(VB_GENERAL, LOG_INFO, "SIGHUP received, rolling log files.");

/* SIGHUP was sent. Close and reopen debug logfiles */
QMutexLocker locker(&loggerListMutex);
Expand Down Expand Up @@ -828,7 +828,7 @@ void logStart(QString logfile, int quiet, int facility, LogLevel_t level,
return;

logLevel = level;
LOG(VB_IMPORTANT, LOG_CRIT, QString("Setting Log Level to %1")
LOG(VB_GENERAL, LOG_CRIT, QString("Setting Log Level to %1")
.arg(LogLevelNames[logLevel]));

logPropagateOpts.propagate = propagate;
Expand Down Expand Up @@ -856,7 +856,7 @@ void logStart(QString logfile, int quiet, int facility, LogLevel_t level,
#ifndef _WIN32
/* Syslog */
if( facility == -1 )
LOG(VB_IMPORTANT, LOG_CRIT,
LOG(VB_GENERAL, LOG_CRIT,
"Syslogging facility unknown, disabling syslog output");
else if( facility >= 0 )
logger = new SyslogLogger(facility);
Expand All @@ -868,7 +868,7 @@ void logStart(QString logfile, int quiet, int facility, LogLevel_t level,

#ifndef _WIN32
/* Setup SIGHUP */
LOG(VB_IMPORTANT, LOG_CRIT, "Setting up SIGHUP handler");
LOG(VB_GENERAL, LOG_CRIT, "Setting up SIGHUP handler");
struct sigaction sa;
sa.sa_sigaction = logSighup;
sigemptyset( &sa.sa_mask );
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/mythlogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extern MBASE_PUBLIC int LogLevelNameCount;
extern MBASE_PUBLIC char *LogLevelShortNames[];
extern MBASE_PUBLIC int LogLevelShortNameCount;
#endif
extern MBASE_PUBLIC LogLevel_t LogLevel;
extern MBASE_PUBLIC LogLevel_t logLevel;

typedef struct
{
Expand Down Expand Up @@ -255,7 +255,7 @@ extern MBASE_PUBLIC QString verboseString;

MBASE_PUBLIC int verboseArgParse(QString arg);

/// This can be appended to the VERBOSE args with
/// This can be appended to the LOG args with
/// "+". Please do not use "<<". It uses
/// a thread safe version of strerror to produce the
/// string representation of errno and puts it on the
Expand Down
31 changes: 16 additions & 15 deletions mythtv/libs/libmythbase/mythmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ bool MythMediaDevice::performMountCmd(bool DoMount)
{
if (DoMount && isMounted())
{
VERBOSE(VB_MEDIA, "MythMediaDevice::performMountCmd(true)"
" - Logic Error? Device already mounted.");
LOG(VB_MEDIA, LOG_ERR, "MythMediaDevice::performMountCmd(true)"
" - Logic Error? Device already mounted.");
return true;
}

Expand All @@ -134,7 +134,7 @@ bool MythMediaDevice::performMountCmd(bool DoMount)
.arg((DoMount) ? PATHTO_MOUNT : PATHTO_UNMOUNT)
.arg(m_DevicePath);

VERBOSE(VB_MEDIA, QString("Executing '%1'").arg(MountCommand));
LOG(VB_MEDIA, LOG_INFO, QString("Executing '%1'").arg(MountCommand));
if (myth_system(MountCommand, kMSDontBlockInputDevs) == GENERIC_EXIT_OK)
{
if (DoMount)
Expand All @@ -143,13 +143,13 @@ bool MythMediaDevice::performMountCmd(bool DoMount)
// so verify the mount status of the device
if (!findMountPath())
{
VERBOSE(VB_MEDIA, "performMountCmd() attempted to"
" find mounted media, but failed?");
LOG(VB_MEDIA, LOG_ERR, "performMountCmd() attempted to"
" find mounted media, but failed?");
return false;
}
m_Status = MEDIASTAT_MOUNTED;
onDeviceMounted();
VERBOSE(VB_GENERAL,
LOG(VB_GENERAL, LOG_INFO,
QString("Detected MediaType ") + MediaTypeString());
}
else
Expand All @@ -158,19 +158,19 @@ bool MythMediaDevice::performMountCmd(bool DoMount)
return true;
}
else
VERBOSE(VB_GENERAL, QString("Failed to mount %1.")
LOG(VB_GENERAL, LOG_ERR, QString("Failed to mount %1.")
.arg(m_DevicePath));
}
else
{
VERBOSE(VB_MEDIA, "Disk inserted on a supermount device");
LOG(VB_MEDIA, LOG_INFO, "Disk inserted on a supermount device");
// If it's a super mount then the OS will handle mounting / unmounting.
// We just need to give derived classes a chance to perform their
// mount / unmount logic.
if (DoMount)
{
onDeviceMounted();
VERBOSE(VB_GENERAL,
LOG(VB_GENERAL, LOG_INFO,
QString("Detected MediaType ") + MediaTypeString());
}
else
Expand All @@ -191,7 +191,8 @@ MythMediaType MythMediaDevice::DetectMediaType(void)

if (!ScanMediaType(m_MountPath, ext_cnt))
{
VERBOSE(VB_MEDIA, QString("No files with extensions found in '%1'")
LOG(VB_MEDIA, LOG_NOTICE,
QString("No files with extensions found in '%1'")
.arg(m_MountPath));
return mediatype;
}
Expand Down Expand Up @@ -314,7 +315,7 @@ bool MythMediaDevice::isSameDevice(const QString &path)

void MythMediaDevice::setSpeed(int speed)
{
VERBOSE(VB_MEDIA,
LOG(VB_MEDIA, LOG_ERR,
QString("Cannot setSpeed(%1) for device %2 - not implemented.")
.arg(speed).arg(m_DevicePath));
}
Expand Down Expand Up @@ -353,8 +354,7 @@ bool MythMediaDevice::findMountPath()
{
if (m_DevicePath.isEmpty())
{
VERBOSE(VB_MEDIA,
LOC + ":findMountPath() - logic error, no device path");
LOG(VB_MEDIA, LOG_ERR, "findMountPath() - logic error, no device path");
return false;
}

Expand Down Expand Up @@ -441,13 +441,14 @@ bool MythMediaDevice::findMountPath()
+ " -----------------+-------------------\n"
+ debug
+ " =================+===================";
VERBOSE(VB_MEDIA, debug);
LOG(VB_MEDIA, LOG_DEBUG, debug);
}

return false;
}

MythMediaStatus MythMediaDevice::setStatus( MythMediaStatus NewStatus, bool CloseIt )
MythMediaStatus MythMediaDevice::setStatus( MythMediaStatus NewStatus,
bool CloseIt )
{
MythMediaStatus OldStatus = m_Status;

Expand Down
Loading