The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

94 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_LOGGER_JUCEHEADER__
  19. #define __JUCE_LOGGER_JUCEHEADER__
  20. #include "../text/juce_String.h"
  21. //==============================================================================
  22. /**
  23. Acts as an application-wide logging class.
  24. A subclass of Logger can be created and passed into the Logger::setCurrentLogger
  25. method and this will then be used by all calls to writeToLog.
  26. The logger class also contains methods for writing messages to the debugger's
  27. output stream.
  28. @see FileLogger
  29. */
  30. class JUCE_API Logger
  31. {
  32. public:
  33. //==============================================================================
  34. /** Destructor. */
  35. virtual ~Logger();
  36. //==============================================================================
  37. /** Sets the current logging class to use.
  38. Note that the object passed in will not be owned or deleted by the logger, so
  39. the caller must make sure that it is not deleted while still being used.
  40. A null pointer can be passed-in to disable any logging.
  41. */
  42. static void JUCE_CALLTYPE setCurrentLogger (Logger* newLogger) noexcept;
  43. /** Writes a string to the current logger.
  44. This will pass the string to the logger's logMessage() method if a logger
  45. has been set.
  46. @see logMessage
  47. */
  48. static void JUCE_CALLTYPE writeToLog (const String& message);
  49. //==============================================================================
  50. /** Writes a message to the standard error stream.
  51. This can be called directly, or by using the DBG() macro in
  52. juce_PlatformDefs.h (which will avoid calling the method in non-debug builds).
  53. */
  54. static void JUCE_CALLTYPE outputDebugString (const String& text);
  55. protected:
  56. //==============================================================================
  57. Logger();
  58. /** This is overloaded by subclasses to implement custom logging behaviour.
  59. @see setCurrentLogger
  60. */
  61. virtual void logMessage (const String& message) = 0;
  62. private:
  63. static Logger* currentLogger;
  64. };
  65. #endif // __JUCE_LOGGER_JUCEHEADER__