💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.9 KiB

  1. /*
  2. * Copyright (C) 2017-2019 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper Source Code.
  5. *
  6. * Antkeeper Source Code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper Source Code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper Source Code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef LOGGER_HPP
  20. #define LOGGER_HPP
  21. #include <ostream>
  22. #include <string>
  23. class Logger
  24. {
  25. public:
  26. Logger();
  27. ~Logger();
  28. /**
  29. * Redirects log output to the specified output stream.
  30. *
  31. * @param stream Output stream to which log text will be written.
  32. */
  33. void redirect(std::ostream* stream);
  34. /**
  35. * Outputs text to the log.
  36. */
  37. void log(const std::string& text);
  38. void warning(const std::string& text);
  39. void error(const std::string& text);
  40. void success(const std::string& text);
  41. void setLogPrefix(const std::string& prefix);
  42. void setLogPostfix(const std::string& postfix);
  43. void setWarningPrefix(const std::string& prefix);
  44. void setWarningPostfix(const std::string& postfix);
  45. void setErrorPrefix(const std::string& prefix);
  46. void setErrorPostfix(const std::string& postfix);
  47. void setSuccessPrefix(const std::string& prefix);
  48. void setSuccessPostfix(const std::string& postfix);
  49. private:
  50. std::ostream* os;
  51. std::string logPrefix;
  52. std::string logPostfix;
  53. std::string warningPrefix;
  54. std::string warningPostfix;
  55. std::string errorPrefix;
  56. std::string errorPostfix;
  57. std::string successPrefix;
  58. std::string successPostfix;
  59. };
  60. #endif // LOGGER_HPP