Logger.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreString.h>
  17. #include <OgreUTFString.h>
  18. /**
  19. * Converts an hexadecimal value to a string.
  20. *
  21. * @param value[in] The value to convert.
  22. * @param width[in] Word width.
  23. * @param fill[in] Filling character for word alignment.
  24. * @return String representation of the value.
  25. */
  26. Ogre::String HexToString(int value, unsigned short width, char fill);
  27. /**
  28. * Converts a boolean value to a string.
  29. *
  30. * @param value[in] The value to convert.
  31. * @return String representation of the value. 'true' if the value is true,
  32. * 'false' otherwise.
  33. */
  34. Ogre::String BoolToString(bool value);
  35. /**
  36. * Converts an integer value to a string.
  37. *
  38. * @param value[in] The value to convert.
  39. * @return String representation of the value.
  40. */
  41. Ogre::String IntToString(int value);
  42. /**
  43. * Converts a real value to a string.
  44. *
  45. * @param value[in] The value to convert.
  46. * @return String representation of the value.
  47. */
  48. Ogre::String FloatToString(float value);
  49. /**
  50. * Application logger utility.
  51. */
  52. class Logger{
  53. public:
  54. /**
  55. * Constructor.
  56. *
  57. * @param log_file_name[in] Path to the log file.
  58. */
  59. explicit Logger(const Ogre::String& log_file_name);
  60. /**
  61. * Destructor.
  62. */
  63. virtual ~Logger();
  64. /**
  65. * Logs a message.
  66. *
  67. * @param text[in] Message to log.
  68. */
  69. void Log(const Ogre::String& text);
  70. /**
  71. * Logs a message.
  72. *
  73. * @param text[in] Message to log.
  74. */
  75. void LogW(const Ogre::UTFString& text);
  76. /**
  77. * Logs messages.
  78. *
  79. * @param text[in] Messages to log.
  80. */
  81. void Log(std::vector<unsigned char>& text);
  82. private:
  83. /**
  84. * PAth to the log file.
  85. */
  86. Ogre::String log_file_;
  87. };
  88. /**
  89. * Application logger.
  90. *
  91. * To be used application-wide.
  92. */
  93. extern Logger *LOGGER;