From 6855390664482a9cf804769424f0fdcad2755183 Mon Sep 17 00:00:00 2001 From: monsieurgustav Date: Mon, 6 Apr 2015 13:11:05 +0200 Subject: [PATCH] log base64 encoded incoming/outgoing packets --- OSC/Source/OSC/Private/OscPrivatePCH.h | 1 + OSC/Source/OSC/Private/OscSettings.cpp | 21 +++++++++++++++++-- .../OSC/Private/Receive/OscDispatcher.cpp | 8 ++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/OSC/Source/OSC/Private/OscPrivatePCH.h b/OSC/Source/OSC/Private/OscPrivatePCH.h index 1c38a17..b7efac3 100644 --- a/OSC/Source/OSC/Private/OscPrivatePCH.h +++ b/OSC/Source/OSC/Private/OscPrivatePCH.h @@ -18,6 +18,7 @@ #include "Runtime/Engine/Classes/Kismet/BlueprintFunctionLibrary.h" #include "Runtime/Networking/Public/Networking.h" +#include "Runtime/Core/Public/Misc/Base64.h" #include #include diff --git a/OSC/Source/OSC/Private/OscSettings.cpp b/OSC/Source/OSC/Private/OscSettings.cpp index d8b43ee..4a61050 100644 --- a/OSC/Source/OSC/Private/OscSettings.cpp +++ b/OSC/Source/OSC/Private/OscSettings.cpp @@ -60,12 +60,29 @@ void UOscSettings::Send(const uint8 *buffer, int32 length, int32 targetIndex) { SendImpl(&_sendSocket.Get(), buffer, length, *address.second); } - UE_LOG(LogOSC, Verbose, TEXT("OSC sent")); + + // Log sent packet + if(!LogOSC.IsSuppressed(ELogVerbosity::Verbose)) + { + TArray tmp; + tmp.Append(buffer, length); + const auto encoded = FBase64::Encode(tmp); + UE_LOG(LogOSC, Verbose, TEXT("SentAll: %s"), *encoded); + } } else if(targetIndex < _sendAddresses.Num()) { SendImpl(&_sendSocket.Get(), buffer, length, *_sendAddresses[targetIndex].second); - UE_LOG(LogOSC, Verbose, TEXT("OSC sent")); + + // Log sent packet + if(!LogOSC.IsSuppressed(ELogVerbosity::Verbose)) + { + TArray tmp; + tmp.Append(buffer, length); + const auto encoded = FBase64::Encode(tmp); + const auto target = _sendAddresses[targetIndex].second->ToString(true); + UE_LOG(LogOSC, Verbose, TEXT("SentTo %s: %s"), *target, *encoded); + } } else { diff --git a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp index 8af82f0..3066939 100644 --- a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp +++ b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp @@ -141,7 +141,6 @@ static void SendBundle(TCircularQueueGetData(), data->Num()); @@ -174,6 +173,13 @@ void UOscDispatcher::Callback(const FArrayReaderPtr& data, const FIPv4Endpoint&) nullptr, ENamedThreads::GameThread); } + + // Log received packet + if(!LogOSC.IsSuppressed(ELogVerbosity::Verbose)) + { + const auto encoded = FBase64::Encode(*data); + UE_LOG(LogOSC, Verbose, TEXT("Received: %s"), *encoded); + } } void UOscDispatcher::CallbackMainThread()