CBasicLogConfigurator.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * CBasicLogConfigurator.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CLogger.h"
  12. class CConsoleHandler;
  13. /**
  14. * The basic log configurator reads log properties from the settings.json and
  15. * sets up the logging system. The file path of the log file can be specified
  16. * via the constructor.
  17. */
  18. class DLL_LINKAGE CBasicLogConfigurator
  19. {
  20. public:
  21. /**
  22. * Constructor.
  23. *
  24. * @param fileName The file path of the log file.
  25. *
  26. * @throws std::runtime_error if the configuration has errors
  27. */
  28. CBasicLogConfigurator(const std::string & filePath, CConsoleHandler * console);
  29. private:
  30. /**
  31. * Gets the log level enum from a string.
  32. *
  33. * @param level The log level string to parse.
  34. * @return the corresponding log level enum value
  35. *
  36. * @throws std::runtime_error if the log level is unknown
  37. */
  38. ELogLevel::ELogLevel getLogLevel(const std::string & level) const;
  39. /**
  40. * Gets the console text color enum from a string.
  41. *
  42. * @param colorName The color string to parse.
  43. * @return the corresponding console text color enum value
  44. *
  45. * @throws std::runtime_error if the log level is unknown
  46. */
  47. EConsoleTextColor::EConsoleTextColor getConsoleColor(const std::string & colorName) const;
  48. };