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 /Swiften
parent2fb37ba9d088e0027560a7d4b2b0617043569d55 (diff)
downloadswift-5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a.zip
swift-5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a.tar.bz2
Statically check the log severity level.
Resolves: #1099
Diffstat (limited to 'Swiften')
-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,5 +1,5 @@
/*
- * 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.
*/
@@ -10,7 +10,15 @@
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
@@ -132,7 +132,7 @@ void SOCKS5BytestreamServerSession::process() {
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
@@ -276,25 +276,25 @@ bool CAPICertificate::checkIfSmartCardPresent () {
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;
}