RKLog.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. namespace Rokid.UXR
  2. {
  3. /// <summary>
  4. /// Log Utility
  5. /// </summary>
  6. public class RKLog
  7. {
  8. public enum LogLevel
  9. {
  10. Debug,
  11. Info,
  12. Warning,
  13. Error
  14. }
  15. private static LogLevel logLevel = LogLevel.Info;
  16. private static bool logEnable = true;
  17. public static void SetLogEnable(bool logEnable)
  18. {
  19. RKLog.logEnable = logEnable;
  20. }
  21. public static void SetLogLevel(LogLevel logLevel)
  22. {
  23. RKLog.logLevel = logLevel;
  24. }
  25. public static void Info(string msg)
  26. {
  27. if (logLevel <= LogLevel.Info && logEnable)
  28. {
  29. UnityEngine.Debug.Log($"[RKLogInfo]:{msg}");
  30. }
  31. }
  32. public static void Debug(string msg)
  33. {
  34. if (logLevel <= LogLevel.Debug && logEnable)
  35. {
  36. UnityEngine.Debug.Log($"[RKLogDebug]:{msg}");
  37. }
  38. }
  39. public static void Warning(string msg)
  40. {
  41. if (logLevel <= LogLevel.Warning && logEnable)
  42. {
  43. UnityEngine.Debug.LogWarning($"[RKLogWarning]:{msg}");
  44. }
  45. }
  46. public static void Error(string msg)
  47. {
  48. if (logEnable)
  49. UnityEngine.Debug.LogError($"[RKLogError]:{msg}");
  50. }
  51. public static void KeyInfo(string msg)
  52. {
  53. UnityEngine.Debug.Log($"[RKKeyInfo]:{msg}");
  54. }
  55. }
  56. }