From 5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Tue, 24 Apr 2012 20:01:00 +0200 Subject: Statically check the log severity level. Resolves: #1099 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; } -- cgit v0.10.2-6-g49f6