Skip to content

Commit

Permalink
prefix log levels with LEVEL_ to avoid naming collision with a
Browse files Browse the repository at this point in the history
macro on Windows
  • Loading branch information
Sam Stenvall committed Jan 5, 2016
1 parent 352dde3 commit a93ce5c
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 201 deletions.
32 changes: 16 additions & 16 deletions src/AutoRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const unsigned int AutoRecordings::GetTimerIntIdFromStringId(const std::string &
if (tit->second.GetStringId() == strId)
return tit->second.GetId();
}
Logger::Log(LogLevel::ERROR, "Autorec: Unable to obtain int id for string id %s", strId.c_str());
Logger::Log(LogLevel::LEVEL_ERROR, "Autorec: Unable to obtain int id for string id %s", strId.c_str());
return 0;
}

Expand Down Expand Up @@ -240,7 +240,7 @@ PVR_ERROR AutoRecordings::SendAutorecAdd(const PVR_TIMER &timer)
/* Check for error */
if (htsmsg_get_u32(m, "success", &u32))
{
Logger::Log(LogLevel::ERROR, "malformed addAutorecEntry response: 'success' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed addAutorecEntry response: 'success' missing");
u32 = PVR_ERROR_FAILED;
}
htsmsg_destroy(m);
Expand Down Expand Up @@ -289,7 +289,7 @@ PVR_ERROR AutoRecordings::SendAutorecDelete(const PVR_TIMER &timer)
/* Check for error */
if (htsmsg_get_u32(m, "success", &u32))
{
Logger::Log(LogLevel::ERROR, "malformed deleteAutorecEntry response: 'success' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed deleteAutorecEntry response: 'success' missing");
}
htsmsg_destroy(m);

Expand All @@ -306,7 +306,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
/* Validate/set mandatory fields */
if ((str = htsmsg_get_str(msg, "id")) == NULL)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd/autorecEntryUpdate: 'id' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd/autorecEntryUpdate: 'id' missing");
return false;
}

Expand All @@ -323,7 +323,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'enabled' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'enabled' missing");
return false;
}

Expand All @@ -333,7 +333,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'retention' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'retention' missing");
return false;
}

Expand All @@ -343,7 +343,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd && (m_conn.GetProtocol() >= 24))
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'removal' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'removal' missing");
return false;
}

Expand All @@ -353,7 +353,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'daysOfWeek' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'daysOfWeek' missing");
return false;
}

Expand All @@ -363,7 +363,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'priority' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'priority' missing");
return false;
}

Expand All @@ -373,7 +373,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'start' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'start' missing");
return false;
}

Expand All @@ -383,7 +383,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'startWindow' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'startWindow' missing");
return false;
}

Expand All @@ -393,7 +393,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'startExtra' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'startExtra' missing");
return false;
}

Expand All @@ -403,7 +403,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'stopExtra' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'stopExtra' missing");
return false;
}

Expand All @@ -413,7 +413,7 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t *msg, bool bAdd)
}
else if (bAdd && (m_conn.GetProtocol() >= 20))
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryAdd: 'dupDetect' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryAdd: 'dupDetect' missing");
return false;
}

Expand Down Expand Up @@ -463,10 +463,10 @@ bool AutoRecordings::ParseAutorecDelete(htsmsg_t *msg)
/* Validate/set mandatory fields */
if ((id = htsmsg_get_str(msg, "id")) == NULL)
{
Logger::Log(LogLevel::ERROR, "malformed autorecEntryDelete: 'id' missing");
Logger::Log(LogLevel::LEVEL_ERROR, "malformed autorecEntryDelete: 'id' missing");
return false;
}
Logger::Log(LogLevel::TRACE, "delete autorec entry %s", id);
Logger::Log(LogLevel::LEVEL_TRACE, "delete autorec entry %s", id);

/* Erase */
m_autoRecordings.erase(std::string(id));
Expand Down
60 changes: 30 additions & 30 deletions src/HTSPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ std::string CHTSPConnection::GetWebURL ( const char *fmt, ... )
bool CHTSPConnection::WaitForConnection ( void )
{
if (!m_ready) {
Logger::Log(LogLevel::TRACE, "waiting for registration...");
Logger::Log(LogLevel::LEVEL_TRACE, "waiting for registration...");
m_regCond.Wait(m_mutex, m_ready, Settings::GetInstance().GetConnectTimeout());
}
return m_ready;
Expand Down Expand Up @@ -171,7 +171,7 @@ void CHTSPConnection::OnSleep ( void )
{
CLockObject lock(m_mutex);

Logger::Log(LogLevel::TRACE, "going to sleep (OnSleep)");
Logger::Log(LogLevel::LEVEL_TRACE, "going to sleep (OnSleep)");

/* close connection, prevent reconnect while suspending/suspended */
m_suspended = true;
Expand All @@ -181,7 +181,7 @@ void CHTSPConnection::OnWake ( void )
{
CLockObject lock(m_mutex);

Logger::Log(LogLevel::TRACE, "waking up (OnWake)");
Logger::Log(LogLevel::LEVEL_TRACE, "waking up (OnWake)");

/* recreate connection */
m_suspended = false;
Expand Down Expand Up @@ -233,7 +233,7 @@ bool CHTSPConnection::ReadMessage ( void )
r = m_socket->Read((char*)buf + cnt, len - cnt, Settings::GetInstance().GetResponseTimeout());
if (r < 0)
{
Logger::Log(LogLevel::ERROR, "failed to read packet (%s)",
Logger::Log(LogLevel::LEVEL_ERROR, "failed to read packet (%s)",
m_socket->GetError().c_str());
free(buf);
return false;
Expand All @@ -245,14 +245,14 @@ bool CHTSPConnection::ReadMessage ( void )
if (!(msg = htsmsg_binary_deserialize(buf, len, buf)))
{
/* Do not free buf here. Already done by htsmsg_binary_deserialize. */
Logger::Log(LogLevel::ERROR, "failed to decode message");
Logger::Log(LogLevel::LEVEL_ERROR, "failed to decode message");
return false;
}

/* Sequence number - response */
if (htsmsg_get_u32(msg, "seq", &seq) == 0)
{
Logger::Log(LogLevel::TRACE, "received response [%d]", seq);
Logger::Log(LogLevel::LEVEL_TRACE, "received response [%d]", seq);
CLockObject lock(m_mutex);
CHTSPResponseList::iterator it;
if ((it = m_messages.find(seq)) != m_messages.end())
Expand All @@ -265,11 +265,11 @@ bool CHTSPConnection::ReadMessage ( void )
/* Get method */
if (!(method = htsmsg_get_str(msg, "method")))
{
Logger::Log(LogLevel::ERROR, "message without a method");
Logger::Log(LogLevel::LEVEL_ERROR, "message without a method");
htsmsg_destroy(msg);
return true;
}
Logger::Log(LogLevel::TRACE, "receive message [%s]", method);
Logger::Log(LogLevel::LEVEL_TRACE, "receive message [%s]", method);

/* Pass (if return is true, message is finished) */
if (tvh->ProcessMessage(method, msg))
Expand All @@ -292,11 +292,11 @@ bool CHTSPConnection::SendMessage0 ( const char *method, htsmsg_t *msg )

if (!htsmsg_get_u32(msg, "seq", &seq))
{
Logger::Log(LogLevel::TRACE, "sending message [%s : %d]", method, seq);
Logger::Log(LogLevel::LEVEL_TRACE, "sending message [%s : %d]", method, seq);
}
else
{
Logger::Log(LogLevel::TRACE, "sending message [%s]", method);
Logger::Log(LogLevel::LEVEL_TRACE, "sending message [%s]", method);
}
htsmsg_add_str(msg, "method", method);

Expand All @@ -311,7 +311,7 @@ bool CHTSPConnection::SendMessage0 ( const char *method, htsmsg_t *msg )
free(buf);
if (c != (ssize_t)len)
{
Logger::Log(LogLevel::ERROR, "failed to write (%s)",
Logger::Log(LogLevel::LEVEL_ERROR, "failed to write (%s)",
m_socket->GetError().c_str());
if (!m_suspended)
Disconnect();
Expand Down Expand Up @@ -341,7 +341,7 @@ htsmsg_t *CHTSPConnection::SendAndWait0 ( const char *method, htsmsg_t *msg, int
if (!SendMessage0(method, msg))
{
m_messages.erase(seq);
Logger::Log(LogLevel::ERROR, "failed to transmit");
Logger::Log(LogLevel::LEVEL_ERROR, "failed to transmit");
return NULL;
}

Expand All @@ -351,7 +351,7 @@ htsmsg_t *CHTSPConnection::SendAndWait0 ( const char *method, htsmsg_t *msg, int
if (!msg)
{
//XBMC->QueueNotification(QUEUE_ERROR, "Command %s failed: No response received", method);
Logger::Log(LogLevel::ERROR, "Command %s failed: No response received", method);
Logger::Log(LogLevel::LEVEL_ERROR, "Command %s failed: No response received", method);
if (!m_suspended)
Disconnect();
return NULL;
Expand All @@ -363,7 +363,7 @@ htsmsg_t *CHTSPConnection::SendAndWait0 ( const char *method, htsmsg_t *msg, int
{
// access denied
//XBMC->QueueNotification(QUEUE_ERROR, "Command %s failed: Access denied", method);
Logger::Log(LogLevel::ERROR, "Command %s failed: Access denied", method);
Logger::Log(LogLevel::LEVEL_ERROR, "Command %s failed: Access denied", method);
htsmsg_destroy(msg);
return NULL;
}
Expand All @@ -373,7 +373,7 @@ htsmsg_t *CHTSPConnection::SendAndWait0 ( const char *method, htsmsg_t *msg, int
if((strError = htsmsg_get_str(msg, "error")) != NULL)
{
//XBMC->QueueNotification(QUEUE_ERROR, "Command %s failed: %s", method, strError);
Logger::Log(LogLevel::ERROR, "Command %s failed: %s", method, strError);
Logger::Log(LogLevel::LEVEL_ERROR, "Command %s failed: %s", method, strError);
htsmsg_destroy(msg);
return NULL;
}
Expand Down Expand Up @@ -418,7 +418,7 @@ bool CHTSPConnection::SendHello ( void )
m_serverVersion = htsmsg_get_str(msg, "serverversion");
m_htspVersion = htsmsg_get_u32_or_default(msg, "htspversion", 0);
m_webRoot = webroot ? webroot : "";
Logger::Log(LogLevel::DEBUG, "connected to %s / %s (HTSPv%d)",
Logger::Log(LogLevel::LEVEL_DEBUG, "connected to %s / %s (HTSPv%d)",
m_serverName.c_str(), m_serverVersion.c_str(), m_htspVersion);

/* Capabilities */
Expand Down Expand Up @@ -482,34 +482,34 @@ void CHTSPConnection::Register ( void )
CLockObject lock(m_mutex);

/* Send Greeting */
Logger::Log(LogLevel::DEBUG, "sending hello");
Logger::Log(LogLevel::LEVEL_DEBUG, "sending hello");
if (!SendHello()) {
Logger::Log(LogLevel::ERROR, "failed to send hello");
Logger::Log(LogLevel::LEVEL_ERROR, "failed to send hello");
goto fail;
}

/* Check htsp server version against client minimum htsp version */
if (m_htspVersion < HTSP_MIN_SERVER_VERSION)
{
Logger::Log(LogLevel::ERROR, "server htsp version (v%d) does not match minimum htsp version required by client (v%d)", m_htspVersion, HTSP_MIN_SERVER_VERSION);
Logger::Log(LogLevel::LEVEL_ERROR, "server htsp version (v%d) does not match minimum htsp version required by client (v%d)", m_htspVersion, HTSP_MIN_SERVER_VERSION);
Disconnect();
m_ready = false;
m_regCond.Broadcast();
return;
}

/* Send Auth */
Logger::Log(LogLevel::DEBUG, "sending auth");
Logger::Log(LogLevel::LEVEL_DEBUG, "sending auth");

if (!SendAuth(user, pass))
goto fail;

/* Rebuild state */
Logger::Log(LogLevel::DEBUG, "rebuilding state");
Logger::Log(LogLevel::LEVEL_DEBUG, "rebuilding state");
if (!tvh->Connected())
goto fail;

Logger::Log(LogLevel::DEBUG, "registered");
Logger::Log(LogLevel::LEVEL_DEBUG, "registered");
m_ready = true;
m_regCond.Broadcast();
return;
Expand All @@ -531,7 +531,7 @@ void* CHTSPConnection::Process ( void )

while (!IsStopped())
{
Logger::Log(LogLevel::DEBUG, "new connection requested");
Logger::Log(LogLevel::LEVEL_DEBUG, "new connection requested");

std::string host = settings.GetHostname();
int port, timeout;
Expand All @@ -555,28 +555,28 @@ void* CHTSPConnection::Process ( void )

while (m_suspended)
{
Logger::Log(LogLevel::DEBUG, "suspended. Waiting for wakeup...");
Logger::Log(LogLevel::LEVEL_DEBUG, "suspended. Waiting for wakeup...");

/* Wait for wakeup */
Sleep(1000);
}

if (!log)
{
Logger::Log(LogLevel::DEBUG, "connecting to %s:%d", host.c_str(), port);
Logger::Log(LogLevel::LEVEL_DEBUG, "connecting to %s:%d", host.c_str(), port);
log = true;
}
else
{
Logger::Log(LogLevel::TRACE, "connecting to %s:%d", host.c_str(), port);
Logger::Log(LogLevel::LEVEL_TRACE, "connecting to %s:%d", host.c_str(), port);
}

/* Connect */
Logger::Log(LogLevel::TRACE, "waiting for connection...");
Logger::Log(LogLevel::LEVEL_TRACE, "waiting for connection...");
if (!m_socket->Open(timeout))
{
/* Unable to connect */
Logger::Log(LogLevel::ERROR, "unable to connect to %s:%d", host.c_str(), port);
Logger::Log(LogLevel::LEVEL_ERROR, "unable to connect to %s:%d", host.c_str(), port);

// Retry a few times with a short interval, after that with the default timeout
if (++retryAttempt <= FAST_RECONNECT_ATTEMPTS)
Expand All @@ -586,7 +586,7 @@ void* CHTSPConnection::Process ( void )

continue;
}
Logger::Log(LogLevel::DEBUG, "connected");
Logger::Log(LogLevel::LEVEL_DEBUG, "connected");
log = false;
retryAttempt = 0;

Expand All @@ -598,7 +598,7 @@ void* CHTSPConnection::Process ( void )
{
if (!ReadMessage())
{
Logger::Log(LogLevel::DEBUG, "attempting reconnect");
Logger::Log(LogLevel::LEVEL_DEBUG, "attempting reconnect");
break;
}
}
Expand Down
Loading

0 comments on commit a93ce5c

Please sign in to comment.