IUnityLog.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Unity Native Plugin API copyright © 2015 Unity Technologies ApS
  2. //
  3. // Licensed under the Unity Companion License for Unity - dependent projects--see[Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
  4. //
  5. // Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.Please review the license for details on these and other terms and conditions.
  6. #pragma once
  7. #include "IUnityInterface.h"
  8. /// The type of the log message
  9. enum UnityLogType
  10. {
  11. /// UnityLogType used for Errors.
  12. kUnityLogTypeError = 0,
  13. /// UnityLogType used for Warnings.
  14. kUnityLogTypeWarning = 2,
  15. /// UnityLogType used for regular log messages.
  16. kUnityLogTypeLog = 3,
  17. /// UnityLogType used for Exceptions.
  18. kUnityLogTypeException = 4,
  19. };
  20. #define UNITY_WRAP_CODE(CODE_) do { CODE_; } while (0)
  21. #define UNITY_LOG(PTR_, MSG_) UNITY_WRAP_CODE((PTR_)->Log(kUnityLogTypeLog, MSG_, __FILE__, __LINE__))
  22. #define UNITY_LOG_WARNING(PTR_, MSG_) UNITY_WRAP_CODE((PTR_)->Log(kUnityLogTypeWarning, MSG_, __FILE__, __LINE__))
  23. #define UNITY_LOG_ERROR(PTR_, MSG_) UNITY_WRAP_CODE((PTR_)->Log(kUnityLogTypeError, MSG_, __FILE__, __LINE__))
  24. UNITY_DECLARE_INTERFACE(IUnityLog)
  25. {
  26. // Writes information message to Unity log.
  27. // \param type type log channel type which defines importance of the message.
  28. // \param message UTF-8 null terminated string.
  29. // \param fileName UTF-8 null terminated string with file name of the point where message is generated.
  30. // \param fileLine integer file line number of the point where message is generated.
  31. void(UNITY_INTERFACE_API * Log)(UnityLogType type, const char* message, const char *fileName, const int fileLine);
  32. };
  33. UNITY_REGISTER_INTERFACE_GUID(0x9E7507fA5B444D5DULL, 0x92FB979515EA83FCULL, IUnityLog)