diff --git a/BeastConfig.h b/BeastConfig.h index 29fd836456..2d08bcb6e6 100644 --- a/BeastConfig.h +++ b/BeastConfig.h @@ -20,4 +20,6 @@ //#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES #endif +#define RIPPLE_USE_NAMESPACE 0 + #endif diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj index af5813bb71..01baef45f7 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj +++ b/Builds/VisualStudio2012/RippleD.vcxproj @@ -183,6 +183,12 @@ true true + + true + true + true + true + true @@ -1242,12 +1248,6 @@ true true - - true - true - true - true - true true diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters index dff7c556cc..a9e6147ccc 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters @@ -414,9 +414,6 @@ 1. Modules\ripple_app\refactored - - 1. Modules\ripple_app\refactored - 1. Modules\ripple_app\refactored @@ -897,6 +894,9 @@ 1. Modules\ripple_core + + 1. Modules\ripple_websocket\autosocket + diff --git a/modules/ripple_app/ripple_app.cpp b/modules/ripple_app/ripple_app.cpp index 14a7f108f1..5e3817ed16 100644 --- a/modules/ripple_app/ripple_app.cpp +++ b/modules/ripple_app/ripple_app.cpp @@ -375,7 +375,6 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) #include "src/cpp/ripple/ripple_FeeVote.cpp" #include "src/cpp/ripple/ripple_HashedObjectStore.cpp" #include "src/cpp/ripple/ripple_HashRouter.cpp" -//#include "src/cpp/ripple/ripple_InfoSub.cpp" #endif @@ -392,7 +391,6 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) #include "src/cpp/ripple/ripple_LedgerHistory.cpp" #include "src/cpp/ripple/ripple_LoadEvent.cpp" #include "src/cpp/ripple/ripple_LoadMonitor.cpp" -#include "src/cpp/ripple/ripple_LogWebsockets.cpp" #include "src/cpp/ripple/ripple_LoadFeeTrack.cpp" #include "src/cpp/ripple/ripple_OrderBook.cpp" #include "src/cpp/ripple/ripple_PathRequest.cpp" diff --git a/modules/ripple_basics/containers/ripple_RangeSet.h b/modules/ripple_basics/containers/ripple_RangeSet.h index cbed4135d1..fb1fc8412a 100644 --- a/modules/ripple_basics/containers/ripple_RangeSet.h +++ b/modules/ripple_basics/containers/ripple_RangeSet.h @@ -48,16 +48,4 @@ public: std::string toString () const; }; -// VFALCO TODO these parameters should not be const references. -template T range_check_cast (const U& value, const T& minimum, const T& maximum) -{ - if ((value < minimum) || (value > maximum)) - throw std::runtime_error ("Value out of range"); - - return static_cast (value); -} - - #endif - -// vim:ts=4 diff --git a/modules/ripple_basics/ripple_basics.cpp b/modules/ripple_basics/ripple_basics.cpp index b7e4622c50..2ccf2cbfb3 100644 --- a/modules/ripple_basics/ripple_basics.cpp +++ b/modules/ripple_basics/ripple_basics.cpp @@ -10,9 +10,13 @@ @ingroup ripple_basics */ -#include -#include +#include "ripple_basics.h" +#include +#include + +// VFALCO TODO Rewrite Sustain to use beast::Process +// // These are for Sustain Linux variants #ifdef __linux__ #include @@ -27,7 +31,7 @@ #include #include #include -#include // for stupid parseIpPort +#include // VFALCO NOTE just for parseIpPort (!) #include // VFALCO TODO Replace OpenSSL randomness with a dependency-free implementation @@ -39,16 +43,16 @@ // #include // Because of ripple_RandomNumbers.cpp +#ifdef BEAST_WIN32 +#include // for ripple_RandomNumbers.cpp +#include // for ripple_RandomNumbers.cpp +// Winsock #defines 'max' and does other stupid things so put it last +#include // for ripple_ByteOrder.cpp +#endif -#include "ripple_basics.h" - - - -// VFALCO TODO fix these warnings! -#ifdef _MSC_VER -//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length" -//#pragma warning (disable: 4018) // signed/unsigned mismatch -//#pragma warning (disable: 4244) // conversion, possible loss of data +#if RIPPLE_USE_NAMESPACE +namespace ripple +{ #endif #include "containers/ripple_RangeSet.cpp" @@ -65,16 +69,10 @@ #include "utility/ripple_Time.cpp" #include "utility/ripple_UptimeTimer.cpp" -#ifdef WIN32 -#include // for ripple_RandomNumbers.cpp -#include // for ripple_RandomNumbers.cpp -// Winsock #defines 'max' and does other stupid things so put it last -#include // for ripple_ByteOrder.cpp -#endif #include "utility/ripple_RandomNumbers.cpp" // has Win32/Posix dependencies #include "types/ripple_UInt256.cpp" -#ifdef _MSC_VER -//#pragma warning (pop) +#if RIPPLE_USE_NAMESPACE +} #endif diff --git a/modules/ripple_basics/ripple_basics.h b/modules/ripple_basics/ripple_basics.h index 81b307bc11..e0a6f64bb5 100644 --- a/modules/ripple_basics/ripple_basics.h +++ b/modules/ripple_basics/ripple_basics.h @@ -17,41 +17,43 @@ @defgroup ripple_basics */ -#ifndef RIPPLE_BASICS_H -#define RIPPLE_BASICS_H +#ifndef RIPPLE_BASICS_RIPPLEHEADER +#define RIPPLE_BASICS_RIPPLEHEADER -#include -#include -#include -#include -#include - -// UInt256 #include #include #include #include #include +#include #include +#include +#include +#include #include #include #include #if BOOST_VERSION < 104700 -#error Boost 1.47 or later is required +#error Ripple requires Boost version 1.47 or later #endif -#include -#include // VFALCO TODO try to eliminate thie dependency -#include -#include -#include -#include -#include -#include -#include -#include +// VFALCO TODO Move all boost includes into ripple_BoostHeaders.h +// +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // ByteOrder #ifdef WIN32 @@ -64,28 +66,22 @@ # include #endif -// StringUtilities -#include -#include - -// UInt256 -#include - -// ripple_PlatformMacros.h -#include -#include - -// VFALCO TODO remove this dependency!!! #include // for DiffieHellmanUtil #include // For HashUtilities #include // For HashUtilities -#include "BeastConfig.h" +#include "BeastConfig.h" // Must come before any Beast includes + #include "modules/beast_core/beast_core.h" #include "modules/beast_basics/beast_basics.h" #include "../ripple_json/ripple_json.h" +#if RIPPLE_USE_NAMESPACE +namespace ripple +{ +#endif + #include "utility/ripple_IntegerTypes.h" // must come first #include "utility/ripple_Log.h" // Needed by others @@ -111,4 +107,8 @@ #include "containers/ripple_SecureAllocator.h" #include "containers/ripple_TaggedCache.h" +#if RIPPLE_USE_NAMESPACE +} +#endif + #endif diff --git a/modules/ripple_basics/utility/ripple_StringUtilities.h b/modules/ripple_basics/utility/ripple_StringUtilities.h index 4541752a3c..ffa766a818 100644 --- a/modules/ripple_basics/utility/ripple_StringUtilities.h +++ b/modules/ripple_basics/utility/ripple_StringUtilities.h @@ -150,15 +150,6 @@ inline static std::string sqlEscape (Blob const& vecSrc) return j; } -template -bool isZero (Iterator first, int iSize) -{ - while (iSize && !*first++) - --iSize; - - return !iSize; -} - int charUnHex (char cDigit); int strUnHex (std::string& strDst, const std::string& strSrc); diff --git a/modules/ripple_data/protocol/ripple_STAmount.cpp b/modules/ripple_data/protocol/ripple_STAmount.cpp index f0d057094a..ef23958b19 100644 --- a/modules/ripple_data/protocol/ripple_STAmount.cpp +++ b/modules/ripple_data/protocol/ripple_STAmount.cpp @@ -231,9 +231,9 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency) Blob vucVersion = sit.getRaw (16 / 8); Blob vucReserved = sit.getRaw (24 / 8); - bool bIso = ::isZero (vucZeros.begin (), vucZeros.size ()) // Leading zeros - && ::isZero (vucVersion.begin (), vucVersion.size ()) // Zero version - && ::isZero (vucReserved.begin (), vucReserved.size ()); // Reserved is zero. + bool bIso = isZeroFilled (vucZeros.begin (), vucZeros.size ()) // Leading zeros + && isZeroFilled (vucVersion.begin (), vucVersion.size ()) // Zero version + && isZeroFilled (vucReserved.begin (), vucReserved.size ()); // Reserved is zero. if (bIso) { diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.cpp b/modules/ripple_data/protocol/ripple_SerializedObject.cpp index e2e1cad81f..2ab64c0232 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedObject.cpp @@ -1308,14 +1308,29 @@ UPTR_T STObject::parseJson (const Json::Value& object, SField::ref inN case STI_UINT32: if (value.isString ()) + { data.push_back (new STUInt32 (field, lexical_cast_st (value.asString ()))); + } else if (value.isInt ()) - data.push_back (new STUInt32 (field, range_check_cast (value.asInt (), 0, 4294967295u))); + { + // VFALCO NOTE value.asInt() returns an int, which can never be greater than 7fffffff, but we + // are checking to make sure it is not greater than ffffffff, which can never be + // less than any 32 bit value (signed or unsigned). + // + // It seems this line only cares that value.asInt () is not negative, can someone + // confirm this? + // +#pragma message(BEAST_FILEANDLINE_ "Invalid signed/unsigned comparison") + data.push_back (new STUInt32 (field, range_check_cast (value.asInt (), 0u, 4294967295u))); + } else if (value.isUInt ()) + { data.push_back (new STUInt32 (field, static_cast (value.asUInt ()))); + } else + { throw std::runtime_error ("Incorrect type"); - + } break; case STI_UINT64: diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.h b/modules/ripple_data/protocol/ripple_SerializedObject.h index 025ff45693..9cfa818f96 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.h +++ b/modules/ripple_data/protocol/ripple_SerializedObject.h @@ -260,17 +260,29 @@ public: } private: - boost::ptr_vector mData; - const SOTemplate* mType; + // VFALCO TODO these parameters should not be const references. + template + static T range_check_cast (const U& value, const T& minimum, const T& maximum) + { + if ((value < minimum) || (value > maximum)) + throw std::runtime_error ("Value out of range"); + + return static_cast (value); + } STObject* duplicate () const { return new STObject (*this); } + STObject (SField::ref name, boost::ptr_vector& data) : SerializedType (name), mType (NULL) { mData.swap (data); } + +private: + boost::ptr_vector mData; + const SOTemplate* mType; }; //------------------------------------------------------------------------------ @@ -283,17 +295,6 @@ inline STObject::iterator range_end (STObject& x) { return x.end (); } -namespace boost -{ -template<> struct range_mutable_iterator -{ - typedef STObject::iterator type; -}; -template<> struct range_const_iterator -{ - typedef STObject::const_iterator type; -}; -} //------------------------------------------------------------------------------ @@ -481,17 +482,5 @@ inline STArray::iterator range_end (STArray& x) { return x.end (); } -namespace boost -{ -template<> struct range_mutable_iterator -{ - typedef STArray::iterator type; -}; -template<> struct range_const_iterator -{ - typedef STArray::const_iterator type; -}; -} #endif -// vim:ts=4 diff --git a/modules/ripple_data/protocol/ripple_SerializedTypes.h b/modules/ripple_data/protocol/ripple_SerializedTypes.h index 3fd02ea352..20eff2c060 100644 --- a/modules/ripple_data/protocol/ripple_SerializedTypes.h +++ b/modules/ripple_data/protocol/ripple_SerializedTypes.h @@ -728,6 +728,16 @@ public: STAmount getRound () const; void roundSelf (); +private: + template + static bool isZeroFilled (Iterator first, int iSize) + { + while (iSize && !*first++) + --iSize; + + return !iSize; + } + private: uint160 mCurrency; // Compared by ==. Always update mIsNative. uint160 mIssuer; // Not compared by ==. 0 for XRP. @@ -1291,21 +1301,6 @@ inline std::vector::const_iterator range_end (const STPath& x) return x.end (); } -namespace boost -{ -template<> -struct range_mutable_iterator< STPath > -{ - typedef std::vector::iterator type; -}; - -template<> -struct range_const_iterator< STPath > -{ - typedef std::vector::const_iterator type; -}; -} - // A set of zero or more payment paths class STPathSet : public SerializedType { @@ -1423,21 +1418,6 @@ inline std::vector::const_iterator range_end (const STPathSet& x) return x.end (); } -namespace boost -{ -template<> -struct range_mutable_iterator< STPathSet > -{ - typedef std::vector::iterator type; -}; - -template<> -struct range_const_iterator< STPathSet > -{ - typedef std::vector::const_iterator type; -}; -} - class STVector256 : public SerializedType { public: diff --git a/modules/ripple_data/ripple_data.cpp b/modules/ripple_data/ripple_data.cpp index 49fc0392b9..9cb8edb024 100644 --- a/modules/ripple_data/ripple_data.cpp +++ b/modules/ripple_data/ripple_data.cpp @@ -10,13 +10,14 @@ @ingroup ripple_data */ -#include +#include "ripple_data.h" #include #include #include #include #include +#include #include #include #include @@ -40,22 +41,24 @@ #include #include #include -#include +//#include // includes and causes errors due to #define GetMessage #include // VFALCO TODO fix these warnings! -#ifdef _MSC_VER -//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length" +#if BEAST_MSVC +#pragma warning (push) #pragma warning (disable: 4018) // signed/unsigned mismatch -//#pragma warning (disable: 4244) // conversion, possible loss of data #endif -#include "ripple_data.h" - #ifdef min #undef min #endif +#if RIPPLE_USE_NAMESPACE +namespace ripple +{ +#endif + #include "crypto/ripple_Base58.h" // for RippleAddress #include "crypto/ripple_CKey.h" // needs RippleAddress VFALCO TODO remove this dependency cycle #include "crypto/ripple_RFC1751.h" @@ -90,11 +93,15 @@ static const uint64 tenTo17m1 = tenTo17 - 1; #include "utility/ripple_JSONCache.cpp" -// VFALCO TODO Fix this for SConstruct -#ifdef _MSC_VER -#include "ripple.pb.cc" // BROKEN because of SConstruct +#if RIPPLE_USE_NAMESPACE +} #endif -#ifdef _MSC_VER -//#pragma warning (pop) +// VFALCO TODO Fix this for SConstruct +#if BEAST_MSVC +#include "ripple.pb.cc" +#endif + +#if BEAST_MSVC +#pragma warning (pop) #endif diff --git a/modules/ripple_data/ripple_data.h b/modules/ripple_data/ripple_data.h index 7f477984e2..bfef508e51 100644 --- a/modules/ripple_data/ripple_data.h +++ b/modules/ripple_data/ripple_data.h @@ -17,8 +17,8 @@ @defgroup ripple_data */ -#ifndef RIPPLE_DATA_H -#define RIPPLE_DATA_H +#ifndef RIPPLE_DATA_RIPPLEHEADER +#define RIPPLE_DATA_RIPPLEHEADER #include #include @@ -52,6 +52,11 @@ // additional hierarchy via directories. #include "ripple.pb.h" +#if RIPPLE_USE_NAMESPACE +namespace ripple +{ +#endif + #include "crypto/ripple_CBigNum.h" #include "crypto/ripple_Base58.h" // VFALCO TODO Can be moved to .cpp if we clean up setAlphabet stuff #include "crypto/ripple_Base58Data.h" @@ -75,4 +80,112 @@ #include "utility/ripple_JSONCache.h" #include "utility/ripple_UptimeTimerAdapter.h" +#if RIPPLE_USE_NAMESPACE +} +#endif + +#if RIPPLE_USE_NAMESPACE +namespace boost +{ + template <> + struct range_mutable_iterator + { + typedef std::vector ::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef std::vector ::const_iterator type; + }; + + template <> + struct range_mutable_iterator + { + typedef std::vector ::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef std::vector ::const_iterator type; + }; + + template <> + struct range_mutable_iterator + { + typedef ripple::STObject::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef ripple::STObject::const_iterator type; + }; + + template <> + struct range_mutable_iterator + { + typedef ripple::STArray::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef ripple::STArray::const_iterator type; + }; +} +#else +namespace boost +{ + template <> + struct range_mutable_iterator + { + typedef std::vector ::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef std::vector ::const_iterator type; + }; + + template <> + struct range_mutable_iterator + { + typedef std::vector ::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef std::vector ::const_iterator type; + }; + + template <> + struct range_mutable_iterator + { + typedef STObject::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef STObject::const_iterator type; + }; + + template <> + struct range_mutable_iterator + { + typedef STArray::iterator type; + }; + + template <> + struct range_const_iterator + { + typedef STArray::const_iterator type; + }; +} +#endif + #endif diff --git a/modules/ripple_json/ripple_json.cpp b/modules/ripple_json/ripple_json.cpp index 40a531250a..6dabe12ff8 100644 --- a/modules/ripple_json/ripple_json.cpp +++ b/modules/ripple_json/ripple_json.cpp @@ -12,17 +12,8 @@ #include "ripple_json.h" -// VFALCO TODO Remove unneeded includes -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include #ifdef JSON_USE_CPPTL # include @@ -39,11 +30,15 @@ #define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw #define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message ); -//#if _MSC_VER >= 1400 // VC++ 8.0 -//#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. -//#endif +#if RIPPLE_USE_NAMESPACE +namespace ripple +{ +#endif #include "json/json_reader.cpp" #include "json/json_value.cpp" #include "json/json_writer.cpp" +#if RIPPLE_USE_NAMESPACE +} +#endif diff --git a/modules/ripple_json/ripple_json.h b/modules/ripple_json/ripple_json.h index 5dfdc2b1d0..ecbfa700f8 100644 --- a/modules/ripple_json/ripple_json.h +++ b/modules/ripple_json/ripple_json.h @@ -17,34 +17,39 @@ @defgroup ripple_json */ -#ifndef RIPPLE_JSON_H -#define RIPPLE_JSON_H +#ifndef RIPPLE_JSON_RIPPLEHEADER +#define RIPPLE_JSON_RIPPLEHEADER -// VFALCO TODO Remove unneeded includes -#include -#include -#include #include -#include #include +#include #include -// Needed before these cpptl includes -#include "json/json_config.h" +#include "json/json_config.h" // Needed before these cpptl includes #ifndef JSON_USE_CPPTL_SMALLMAP # include #else # include #endif + #ifdef JSON_USE_CPPTL # include #endif +#if RIPPLE_USE_NAMESPACE +namespace ripple +{ +#endif + #include "json/json_forwards.h" #include "json/json_features.h" #include "json/json_value.h" #include "json/json_reader.h" #include "json/json_writer.h" +#if RIPPLE_USE_NAMESPACE +} +#endif + #endif diff --git a/modules/ripple_sqlite/ripple_sqlite.c b/modules/ripple_sqlite/ripple_sqlite.c index f12e055f6e..d04723a607 100644 --- a/modules/ripple_sqlite/ripple_sqlite.c +++ b/modules/ripple_sqlite/ripple_sqlite.c @@ -50,7 +50,7 @@ // VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens. #if SQLITE_THREADSAFE != 2 -#pragma message(BEAST_FILEANDLINE_"Possible performance issue, SQLITE_THREADSAFE != 2") +#pragma message(BEAST_FILEANDLINE_ "Possible performance issue, SQLITE_THREADSAFE != 2") #endif #include "sqlite/sqlite3.c" diff --git a/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp b/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp index a20c4d4766..b9d5415fee 100644 --- a/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp +++ b/modules/ripple_websocket/autosocket/ripple_AutoSocket.cpp @@ -4,5 +4,8 @@ */ //============================================================================== +#if RIPPLE_USE_NAMESPACE +ripple::LogPartition AutoSocket::AutoSocketPartition ("AutoSocket"); +#else LogPartition AutoSocket::AutoSocketPartition ("AutoSocket"); - +#endif diff --git a/modules/ripple_websocket/autosocket/ripple_AutoSocket.h b/modules/ripple_websocket/autosocket/ripple_AutoSocket.h index d1f86c6be6..30b20116ff 100644 --- a/modules/ripple_websocket/autosocket/ripple_AutoSocket.h +++ b/modules/ripple_websocket/autosocket/ripple_AutoSocket.h @@ -73,6 +73,10 @@ public: static bool rfc2818_verify (const std::string& domain, bool preverified, boost::asio::ssl::verify_context& ctx) { +#if RIPPLE_USE_NAMESPACE + using namespace ripple; +#endif + if (boost::asio::ssl::rfc2818_verification (domain) (preverified, ctx)) return true; @@ -224,6 +228,10 @@ public: protected: void handle_autodetect (callback cbFunc, const error_code& ec, size_t bytesTransferred) { +#if RIPPLE_USE_NAMESPACE + using namespace ripple; +#endif + if (ec) { Log (lsWARNING, AutoSocketPartition) << "Handle autodetect error: " << ec; @@ -253,8 +261,11 @@ protected: } private: +#if RIPPLE_USE_NAMESPACE + static ripple::LogPartition AutoSocketPartition; +#else static LogPartition AutoSocketPartition; - +#endif socket_ptr mSocket; bool mSecure; diff --git a/src/cpp/ripple/ripple_LogWebsockets.cpp b/modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp similarity index 55% rename from src/cpp/ripple/ripple_LogWebsockets.cpp rename to modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp index 8f8d23494a..f917dfd58f 100644 --- a/src/cpp/ripple/ripple_LogWebsockets.cpp +++ b/modules/ripple_websocket/autosocket/ripple_LogWebsockets.cpp @@ -11,6 +11,44 @@ namespace websocketpp { namespace log { + +#if RIPPLE_USE_NAMESPACE +using namespace ripple; + +LogPartition websocketPartition ("WebSocket"); + +void websocketLog (websocketpp::log::alevel::value v, const std::string& entry) +{ + using namespace ripple; + + if ((v == websocketpp::log::alevel::DEVEL) || (v == websocketpp::log::alevel::DEBUG_CLOSE)) + { + if (websocketPartition.doLog (lsTRACE)) + Log (lsDEBUG, websocketPartition) << entry; + } + else if (websocketPartition.doLog (lsDEBUG)) + Log (lsDEBUG, websocketPartition) << entry; +} + +void websocketLog (websocketpp::log::elevel::value v, const std::string& entry) +{ + using namespace ripple; + + LogSeverity s = lsDEBUG; + + if ((v & websocketpp::log::elevel::INFO) != 0) + s = lsINFO; + else if ((v & websocketpp::log::elevel::FATAL) != 0) + s = lsFATAL; + else if ((v & websocketpp::log::elevel::RERROR) != 0) + s = lsERROR; + else if ((v & websocketpp::log::elevel::WARN) != 0) + s = lsWARNING; + + if (websocketPartition.doLog (s)) + Log (s, websocketPartition) << entry; +} +#else LogPartition websocketPartition ("WebSocket"); void websocketLog (websocketpp::log::alevel::value v, const std::string& entry) @@ -40,6 +78,7 @@ void websocketLog (websocketpp::log::elevel::value v, const std::string& entry) if (websocketPartition.doLog (s)) Log (s, websocketPartition) << entry; } +#endif } } diff --git a/modules/ripple_websocket/ripple_websocket.cpp b/modules/ripple_websocket/ripple_websocket.cpp index 72f1398d7d..c791744e3f 100644 --- a/modules/ripple_websocket/ripple_websocket.cpp +++ b/modules/ripple_websocket/ripple_websocket.cpp @@ -24,3 +24,4 @@ #include "websocket/src/sha1/sha1.cpp" #include "autosocket/ripple_AutoSocket.cpp" +#include "autosocket/ripple_LogWebsockets.cpp" diff --git a/modules/ripple_websocket/ripple_websocket.h b/modules/ripple_websocket/ripple_websocket.h index 150335391f..0e3b7fb1b1 100644 --- a/modules/ripple_websocket/ripple_websocket.h +++ b/modules/ripple_websocket/ripple_websocket.h @@ -21,13 +21,6 @@ @deprecated */ -#include - -#include -#include -#include - -//------------------------------------------------------------------------------ // VFALCO NOTE Log dependencies have wormed their way into websocketpp, // which needs the ripple_basic module to compile. @@ -37,6 +30,14 @@ // #include "../modules/ripple_basics/ripple_basics.h" +#include + +#include +#include +#include + +//------------------------------------------------------------------------------ + // VFALCO TODO This include is just to prevent a warning about // redefinition of __STDC_LIMIT_MACROS. Fix it right. //