CBasicLogConfigurator.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 "../CConsoleHandler.h"
  12. class CConsoleHandler;
  13. class JsonNode;
  14. /// The class CBasicLogConfigurator reads log properties from settings.json and
  15. /// sets up the logging system. Make sure that you use the same configurator object to
  16. /// initialize the whole logging system. If you don't do so, the log file will be overwritten/truncated.
  17. class DLL_LINKAGE CBasicLogConfigurator
  18. {
  19. public:
  20. CBasicLogConfigurator(const std::string & filePath, CConsoleHandler * console);
  21. /// Configures the logging system by parsing the logging settings. It adds the console target and the file target to the global logger.
  22. /// Doesn't throw, but logs on success or fault.
  23. void configure();
  24. /// Configures a default logging system by adding the console target and the file target to the global logger.
  25. void configureDefault();
  26. private:
  27. ELogLevel::ELogLevel getLogLevel(const std::string & level) const;
  28. EConsoleTextColor::EConsoleTextColor getConsoleColor(const std::string & colorName) const;
  29. std::string filePath;
  30. CConsoleHandler * console;
  31. bool appendToLogFile;
  32. };