TraceMessageHook.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <SceneBuilder/TraceMessageHook.h>
  9. #include <AzFramework/StringFunc/StringFunc.h>
  10. #include <AssetBuilderSDK/AssetBuilderBusses.h>
  11. #include <SceneAPI/SceneCore/Utilities/Reporting.h>
  12. namespace SceneBuilder
  13. {
  14. TraceMessageHook::TraceMessageHook()
  15. {
  16. BusConnect();
  17. }
  18. TraceMessageHook::~TraceMessageHook()
  19. {
  20. BusDisconnect();
  21. }
  22. bool TraceMessageHook::OnPrintf(const char* window, [[maybe_unused]] const char* message)
  23. {
  24. if (AzFramework::StringFunc::Equal(window, AZ::SceneAPI::Utilities::ErrorWindow))
  25. {
  26. AZ_Error(window, false, "%s", message);
  27. AssetBuilderSDK::AssetBuilderTraceBus::Broadcast(&AssetBuilderSDK::AssetBuilderTraceBus::Events::IgnoreNextPrintf, 1);
  28. return true;
  29. }
  30. else if (AzFramework::StringFunc::Equal(window, AZ::SceneAPI::Utilities::WarningWindow))
  31. {
  32. AZ_Warning(window, false, "%s", message);
  33. AssetBuilderSDK::AssetBuilderTraceBus::Broadcast(&AssetBuilderSDK::AssetBuilderTraceBus::Events::IgnoreNextPrintf, 1);
  34. return true;
  35. }
  36. else
  37. {
  38. return false;
  39. }
  40. }
  41. } // namespace SceneBuilder