From c218da359ff8c213a5297f6ea0a5b3feaa6db306 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Wed, 28 Aug 2024 23:22:44 +0100 Subject: [PATCH] Logging working cross-platform --- .../Speckle/Interface/Browser/JSPortal.h | 9 ++++++++- .../Serialise/JSBase/JSBaseTransport.cpp | 20 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/SpeckleLib/Speckle/Interface/Browser/JSPortal.h b/SpeckleLib/Speckle/Interface/Browser/JSPortal.h index b9b0c75..dc0833d 100644 --- a/SpeckleLib/Speckle/Interface/Browser/JSPortal.h +++ b/SpeckleLib/Speckle/Interface/Browser/JSPortal.h @@ -9,6 +9,8 @@ #include #endif +#include + namespace speckle::interfac::browser { /*! @@ -71,7 +73,12 @@ namespace speckle::interfac::browser { try { auto engine = getJSEngine(); - OutputDebugString((LPCTSTR)speckle::utility::String{ "\nExecuted:\n" + code}.operator std::u16string().data()); + speckle::utility::String log{"\nExecuted:\n" + code}; +#ifdef macintosh + std::cout << log.data(); +#else + OutputDebugString((LPCTSTR)log.operator std::u16string().data()); +#endif auto result = engine ? engine->ExecuteJS(code) : false; return result; diff --git a/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp b/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp index 34b76d3..6721eef 100644 --- a/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp +++ b/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp @@ -15,6 +15,8 @@ #include #include +#include + using namespace active::serialise; using namespace active::setting; using namespace speckle::serialise; @@ -464,7 +466,14 @@ namespace { --------------------------------------------------------------------*/ void JSBaseTransport::send(Cargo&& cargo, const Identity& identity, GS::Ref& destination) const { doJSBaseExport(cargo, JSBaseIdentity(identity).atStage(root), destination); - OutputDebugString((WCHAR*)String {"\nSent:\n" + convertToJSON(destination)}.operator std::u16string().data()); + + speckle::utility::String log{"\nSent:\n" + convertToJSON(destination)}; +#ifdef macintosh + std::cout << log.data(); +#else + OutputDebugString((LPCTSTR)log.operator std::u16string().data()); +#endif + } //JSBaseTransport::send @@ -478,7 +487,14 @@ void JSBaseTransport::send(Cargo&& cargo, const Identity& identity, GS::Ref source) const { if (!source) throw std::system_error(makeJSBaseError(badSource)); - OutputDebugString((WCHAR*) String{"\nReceived:\n" + convertToJSON(source)}.operator std::u16string().data()); + + speckle::utility::String log{"\nReceived:\n" + convertToJSON(source)}; +#ifdef macintosh + std::cout << log.data(); +#else + OutputDebugString((LPCTSTR)log.operator std::u16string().data()); +#endif + doJSBaseImport(cargo, JSBaseIdentity(identity).atStage(root), *source); } //JSBaseTransport::receive