Logger.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. Open Asset Import Library (ASSIMP)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2008, ASSIMP Development Team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the ASSIMP team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the ASSIMP Development Team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. #ifndef AI_LOGGER_H_INC
  34. #define AI_LOGGER_H_INC
  35. #include <string>
  36. #include "aiDefines.h"
  37. namespace Assimp
  38. {
  39. class LogStream;
  40. // ---------------------------------------------------------------------------
  41. /** @class Logger
  42. * @brief Abstract interface for logger implementations.
  43. */
  44. class ASSIMP_API Logger
  45. {
  46. public:
  47. /** @enum LogSeverity
  48. * @brief Log severity to descripe granuality of logging.
  49. */
  50. enum LogSeverity
  51. {
  52. NORMAL, //!< Normal granlality of logging
  53. VERBOSE //!< Debug infos will be logged, too
  54. };
  55. /** @enum ErrorSeverity
  56. * @brief Description for severity of a log message
  57. */
  58. enum ErrorSeverity
  59. {
  60. DEBUGGING = 1, //!< Debug log message
  61. INFO = 2, //!< Info log message
  62. WARN = 4, //!< Warn log message
  63. ERR = 8 //!< Error log message
  64. };
  65. public:
  66. /** @brief Virtual destructor */
  67. virtual ~Logger();
  68. /** @brief Writes a debug message
  69. * @param message Debug message
  70. */
  71. virtual void debug(const std::string &message)= 0;
  72. /** @brief Writes a info message
  73. * @param message Info message
  74. */
  75. virtual void info(const std::string &message) = 0;
  76. /** @brief Writes a warning message
  77. * @param message Warn message
  78. */
  79. virtual void warn(const std::string &message) = 0;
  80. /** @brief Writes an error message
  81. * @param message Error message
  82. */
  83. virtual void error(const std::string &message) = 0;
  84. /** @brief Set a new log severity.
  85. * @param log_severity New severity for logging
  86. */
  87. virtual void setLogSeverity(LogSeverity log_severity) = 0;
  88. /** @brief Attach a new logstream
  89. * @param pStream Logstream to attach
  90. */
  91. virtual void attachStream(LogStream *pStream, unsigned int severity) = 0;
  92. /** @brief Detach a still attached stream from logger
  93. * @param pStream Logstream instance for detatching
  94. */
  95. virtual void detatchStream(LogStream *pStream, unsigned int severity) = 0;
  96. protected:
  97. /** @brief Default constructor */
  98. Logger();
  99. };
  100. // ---------------------------------------------------------------------------
  101. // Default constructor
  102. inline Logger::Logger()
  103. {
  104. // empty
  105. }
  106. // ---------------------------------------------------------------------------
  107. // Virtual destructor
  108. inline Logger::~Logger()
  109. {
  110. // empty
  111. }
  112. // ---------------------------------------------------------------------------
  113. } // Namespace Assimp
  114. #endif