Guest User

Untitled

a guest
Mar 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include "SpatialOutputDevice.h"
  2.  
  3. FSpatialOutputDevice::FSpatialOutputDevice(USpatialOS* SpatialOSInstance, FString LoggerName)
  4. {
  5. SpatialOS = SpatialOSInstance;
  6. Name = LoggerName;
  7. FilterLevel = ELogVerbosity::All;
  8.  
  9. FOutputDeviceRedirector::Get()->AddOutputDevice(this);
  10. }
  11.  
  12. FSpatialOutputDevice::~FSpatialOutputDevice()
  13. {
  14. FOutputDeviceRedirector::Get()->RemoveOutputDevice(this);
  15. }
  16.  
  17. void FSpatialOutputDevice::Serialize(const TCHAR* InData, ELogVerbosity::Type Verbosity, const class FName& Category)
  18. {
  19. if (Verbosity > FilterLevel || !CategoriesToRedirect.Contains(Category) || !IsValid(SpatialOS))
  20. {
  21. return;
  22. }
  23.  
  24. TSharedPtr<worker::Connection> Connection = SpatialOS->GetConnection().Pin();
  25. if (Connection.IsValid())
  26. {
  27. Connection->SendLogMessage(ConvertLogLevelToSpatial(Verbosity), TCHAR_TO_UTF8(*Name), TCHAR_TO_UTF8(InData));
  28. }
  29. }
  30.  
  31. void FSpatialOutputDevice::AddRedirectCategory(const FName& Category)
  32. {
  33. CategoriesToRedirect.Add(Category);
  34. }
  35.  
  36. void FSpatialOutputDevice::RemoveRedirectCategory(const FName& Category)
  37. {
  38. CategoriesToRedirect.Remove(Category);
  39. }
  40.  
  41. void FSpatialOutputDevice::SetVerbosityFilterLevel(ELogVerbosity::Type Verbosity)
  42. {
  43. FilterLevel = Verbosity;
  44. }
  45.  
  46. worker::LogLevel FSpatialOutputDevice::ConvertLogLevelToSpatial(ELogVerbosity::Type Verbosity)
  47. {
  48. switch (Verbosity)
  49. {
  50. case ELogVerbosity::Fatal:
  51. return worker::LogLevel::kFatal;
  52. case ELogVerbosity::Error:
  53. return worker::LogLevel::kError;
  54. case ELogVerbosity::Warning:
  55. return worker::LogLevel::kWarn;
  56. default:
  57. return worker::LogLevel::kInfo;
  58. }
  59. }
Add Comment
Please, Sign In to add comment