summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-04-24 18:01:00 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-04-24 18:01:00 (GMT)
commit5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a (patch)
treebfd9a95fe77c15c2b076c8f99680d08355245689
parent2fb37ba9d088e0027560a7d4b2b0617043569d55 (diff)
downloadswift-contrib-5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a.zip
swift-contrib-5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a.tar.bz2
Statically check the log severity level.
Resolves: #1099
-rw-r--r--Swiften/Base/Log.h12
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp2
-rw-r--r--Swiften/TLS/CAPICertificate.cpp14
3 files changed, 18 insertions, 10 deletions
diff --git a/Swiften/Base/Log.h b/Swiften/Base/Log.h
index 5e13a20..955227f 100644
--- a/Swiften/Base/Log.h
+++ b/Swiften/Base/Log.h
@@ -1,16 +1,24 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2012 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <iostream>
namespace Swift {
extern bool logging;
+ namespace LogDetail {
+ // Only here to be able to statically check the correctness of the severity levers
+ namespace Severity {
+ enum {
+ debug, warning, error
+ };
+ }
+ }
}
#define SWIFT_LOG(severity) \
- if (!Swift::logging) {} else std::cerr << "[" << #severity << "] " << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << ": "
+ if (!Swift::logging) {} else (void) LogDetail::Severity::severity, std::cerr << "[" << #severity << "] " << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << ": "
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
index f660fda..2260fc20 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerSession.cpp
@@ -126,19 +126,19 @@ void SOCKS5BytestreamServerSession::process() {
append(result, createByteArray("\x00\x03", 2));
result.push_back(static_cast<char>(requestID.size()));
append(result, concat(requestID, createByteArray("\x00\x00", 2)));
if (!readBytestream && !writeBytestream) {
SWIFT_LOG(debug) << "Readstream or Wrtiestream with ID " << streamID << " not found!" << std::endl;
connection->write(result);
finish(true);
}
else {
- SWIFT_LOG(deubg) << "Found " << (readBytestream ? "Readstream" : "Writestream") << ". Sent OK." << std::endl;
+ SWIFT_LOG(debug) << "Found " << (readBytestream ? "Readstream" : "Writestream") << ". Sent OK." << std::endl;
connection->write(result);
bytestreams->serverSessions[streamID] = this;
state = ReadyForTransfer;
}
}
}
}
}
diff --git a/Swiften/TLS/CAPICertificate.cpp b/Swiften/TLS/CAPICertificate.cpp
index 0083b6f..d10ae6d 100644
--- a/Swiften/TLS/CAPICertificate.cpp
+++ b/Swiften/TLS/CAPICertificate.cpp
@@ -270,37 +270,37 @@ static void smartcard_check_status (SCARDCONTEXT hContext,
}
bool CAPICertificate::checkIfSmartCardPresent () {
if (!smartCardReaderName_.empty()) {
DWORD dwState;
smartcard_check_status(scardContext_, smartCardReaderName_.c_str(), cardHandle_, &cardHandle_, &dwState);
switch (dwState) {
case SCARD_ABSENT:
- SWIFT_LOG("DEBUG") << "Card absent." << std::endl;
+ SWIFT_LOG(debug) << "Card absent." << std::endl;
break;
case SCARD_PRESENT:
- SWIFT_LOG("DEBUG") << "Card present." << std::endl;
+ SWIFT_LOG(debug) << "Card present." << std::endl;
break;
case SCARD_SWALLOWED:
- SWIFT_LOG("DEBUG") << "Card swallowed." << std::endl;
+ SWIFT_LOG(debug) << "Card swallowed." << std::endl;
break;
case SCARD_POWERED:
- SWIFT_LOG("DEBUG") << "Card has power." << std::endl;
+ SWIFT_LOG(debug) << "Card has power." << std::endl;
break;
case SCARD_NEGOTIABLE:
- SWIFT_LOG("DEBUG") << "Card reset and waiting PTS negotiation." << std::endl;
+ SWIFT_LOG(debug) << "Card reset and waiting PTS negotiation." << std::endl;
break;
case SCARD_SPECIFIC:
- SWIFT_LOG("DEBUG") << "Card has specific communication protocols set." << std::endl;
+ SWIFT_LOG(debug) << "Card has specific communication protocols set." << std::endl;
break;
default:
- SWIFT_LOG("DEBUG") << "Unknown or unexpected card state." << std::endl;
+ SWIFT_LOG(debug) << "Unknown or unexpected card state." << std::endl;
break;
}
switch (dwState) {
case SCARD_ABSENT:
return false;